diff --git a/app/models/merged/card.rb b/app/models/merged/card.rb index 7b9a343..c9518aa 100644 --- a/app/models/merged/card.rb +++ b/app/models/merged/card.rb @@ -1,12 +1,9 @@ module Merged - class Card < ActiveYaml::Base - set_root_path Rails.root #ouside engines not necessary - include ActiveHash::Associations + class Card < ViewBase + belongs_to :section , class_name: "Merged::Section" - include Optioned - fields :id , :index , :section_id fields :text , :header, :image , :options diff --git a/app/models/merged/page.rb b/app/models/merged/page.rb index 5bbba28..db02c03 100644 --- a/app/models/merged/page.rb +++ b/app/models/merged/page.rb @@ -1,7 +1,6 @@ module Merged - class Page < ActiveYaml::Base - set_root_path Rails.root #ouside engines not necessary - + class Page < ViewBase + # could be config options def self.cms_root "cms" diff --git a/app/models/merged/section.rb b/app/models/merged/section.rb index 3adf0ef..d0c2b26 100644 --- a/app/models/merged/section.rb +++ b/app/models/merged/section.rb @@ -1,12 +1,8 @@ module Merged - class Section < ActiveYaml::Base - set_root_path Rails.root #ouside engines not necessary + class Section < ViewBase - include ActiveHash::Associations belongs_to :page , class_name: "Merged::Page" - include Optioned - fields :id , :name , :page_id , :index fields :template , :card_template fields :header, :text , :image , :options diff --git a/app/models/merged/optioned.rb b/app/models/merged/view_base.rb similarity index 82% rename from app/models/merged/optioned.rb rename to app/models/merged/view_base.rb index a7d027f..8c20949 100644 --- a/app/models/merged/optioned.rb +++ b/app/models/merged/view_base.rb @@ -1,10 +1,13 @@ module Merged - #relies only on @content["options"] - #and a method template_style - # and index - # and is due for a rename - module Optioned + # base class for viewable elements: ie page, section and casrd + # they share the name and options , and the fact that + # they persist in ActiveYaml + + class ViewBase < ActiveYaml::Base + set_root_path Rails.root #ouside engines not necessary + include ActiveHash::Associations + def has_option?(option) options.has_key?(option) and !options[option].blank? end