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 ##.
- .prepare_attributes(hash) ⇒ Object
Instance Method Summary collapse
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 ##
39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/maglev/section.rb', line 39 def self.build(hash) attributes = prepare_attributes(hash) new( attributes.merge( settings: ::Maglev::Section::Setting.build_many(hash['settings']), blocks: ::Maglev::Section::Block.build_many(hash['blocks']) ) ) end |
.prepare_attributes(hash) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/maglev/section.rb', line 50 def self.prepare_attributes(hash) attributes = hash.slice(*HASH_ATTRIBUTES) %w[site_scoped singleton viewport_fixed_position max_width_pane].each do |name| attributes[name] = false if attributes[name].nil? end attributes['insert_button'] = true if attributes['insert_button'].nil? attributes end |
Instance Method Details
#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 |