giving view elements a base class
This commit is contained in:
parent
b4f6e6b894
commit
bd22c1fd95
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user