Class: Maglev::Section
- Inherits:
-
Object
- Object
- Maglev::Section
- Includes:
- ActiveModel::Model, ActiveModel::Serializers::JSON, ContentConcern
- Defined in:
- app/models/maglev/section.rb
Defined Under Namespace
Modules: ContentConcern Classes: Block, Setting, Store
Constant Summary collapse
- HASH_ATTRIBUTES =
%w[id theme name site_scoped singleton viewport_fixed_position insert_button max_width_pane insert_at category blocks_label blocks_presentation sample screenshot_timestamp].freeze
Instance Attribute Summary collapse
-
#blocks ⇒ Object
attributes ##.
-
#blocks_label ⇒ Object
attributes ##.
-
#blocks_presentation ⇒ Object
attributes ##.
-
#category ⇒ Object
attributes ##.
-
#id ⇒ Object
validations ##.
-
#insert_at ⇒ Object
attributes ##.
-
#insert_button ⇒ Object
attributes ##.
-
#max_width_pane ⇒ Object
attributes ##.
-
#name ⇒ Object
attributes ##.
-
#sample ⇒ Object
attributes ##.
-
#screenshot_timestamp ⇒ Object
attributes ##.
-
#settings ⇒ Object
attributes ##.
-
#singleton ⇒ Object
attributes ##.
-
#site_scoped ⇒ Object
attributes ##.
-
#theme ⇒ Object
attributes ##.
-
#viewport_fixed_position ⇒ Object
attributes ##.
Class Method Summary collapse
-
.build(hash) ⇒ Object
class methods ##.
Instance Method Summary collapse
- #assign_attributes_from_yaml(hash) ⇒ Object
- #singleton? ⇒ Boolean
-
#site_scoped? ⇒ Boolean
methods ##.
- #viewport_fixed_position? ⇒ Boolean
Methods included from ContentConcern
Instance Attribute Details
#blocks ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def blocks @blocks end |
#blocks_label ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def blocks_label @blocks_label end |
#blocks_presentation ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def blocks_presentation @blocks_presentation end |
#category ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def category @category end |
#id ⇒ Object
validations ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def id @id end |
#insert_at ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def insert_at @insert_at end |
#insert_button ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def @insert_button end |
#max_width_pane ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def max_width_pane @max_width_pane end |
#name ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def name @name end |
#sample ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def sample @sample end |
#screenshot_timestamp ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def @screenshot_timestamp end |
#settings ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def settings @settings end |
#singleton ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def singleton @singleton end |
#site_scoped ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def site_scoped @site_scoped end |
#theme ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def theme @theme end |
#viewport_fixed_position ⇒ Object
attributes ##
13 14 15 |
# File 'app/models/maglev/section.rb', line 13 def @viewport_fixed_position end |
Class Method Details
.build(hash) ⇒ Object
class methods ##
49 50 51 52 53 |
# File 'app/models/maglev/section.rb', line 49 def self.build(hash) new.tap do |section| section.assign_attributes_from_yaml(hash) end end |
Instance Method Details
#assign_attributes_from_yaml(hash) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/models/maglev/section.rb', line 38 def assign_attributes_from_yaml(hash) attributes = prepare_default_attributes(hash).merge( settings: ::Maglev::Section::Setting.build_many(hash['settings']), blocks: ::Maglev::Section::Block.build_many(hash['blocks']) ) assign_attributes(attributes) end |
#singleton? ⇒ Boolean
30 31 32 |
# File 'app/models/maglev/section.rb', line 30 def singleton? !!singleton end |
#site_scoped? ⇒ Boolean
methods ##
26 27 28 |
# File 'app/models/maglev/section.rb', line 26 def site_scoped? !!site_scoped end |
#viewport_fixed_position? ⇒ Boolean
34 35 36 |
# File 'app/models/maglev/section.rb', line 34 def !! end |