giving view elements a base class
This commit is contained in:
parent
b4f6e6b894
commit
bd22c1fd95
@ -1,12 +1,9 @@
|
|||||||
module Merged
|
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"
|
belongs_to :section , class_name: "Merged::Section"
|
||||||
|
|
||||||
include Optioned
|
|
||||||
|
|
||||||
fields :id , :index , :section_id
|
fields :id , :index , :section_id
|
||||||
fields :text , :header, :image , :options
|
fields :text , :header, :image , :options
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
module Merged
|
module Merged
|
||||||
class Page < ActiveYaml::Base
|
class Page < ViewBase
|
||||||
set_root_path Rails.root #ouside engines not necessary
|
|
||||||
|
|
||||||
# could be config options
|
# could be config options
|
||||||
def self.cms_root
|
def self.cms_root
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
module Merged
|
module Merged
|
||||||
class Section < ActiveYaml::Base
|
class Section < ViewBase
|
||||||
set_root_path Rails.root #ouside engines not necessary
|
|
||||||
|
|
||||||
include ActiveHash::Associations
|
|
||||||
belongs_to :page , class_name: "Merged::Page"
|
belongs_to :page , class_name: "Merged::Page"
|
||||||
|
|
||||||
include Optioned
|
|
||||||
|
|
||||||
fields :id , :name , :page_id , :index
|
fields :id , :name , :page_id , :index
|
||||||
fields :template , :card_template
|
fields :template , :card_template
|
||||||
fields :header, :text , :image , :options
|
fields :header, :text , :image , :options
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
module Merged
|
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)
|
def has_option?(option)
|
||||||
options.has_key?(option) and !options[option].blank?
|
options.has_key?(option) and !options[option].blank?
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user