Class: Maglev::Section::Block
- Inherits:
-
Object
- Object
- Maglev::Section::Block
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/maglev/section/block.rb
Overview
rubocop:disable Style/ClassAndModuleChildren
Instance Attribute Summary collapse
-
#accept ⇒ Object
attributes ##.
-
#limit ⇒ Object
attributes ##.
-
#name ⇒ Object
validation ##.
-
#root ⇒ Object
attributes ##.
-
#settings ⇒ Object
attributes ##.
-
#type ⇒ Object
attributes ##.
Class Method Summary collapse
-
.build(hash) ⇒ Object
class methods ##.
- .build_many(list) ⇒ Object
Instance Method Summary collapse
-
#root? ⇒ Boolean
methods.
Instance Attribute Details
#accept ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/section/block.rb', line 9 def accept @accept end |
#limit ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/section/block.rb', line 9 def limit @limit end |
#name ⇒ Object
validation ##
9 10 11 |
# File 'app/models/maglev/section/block.rb', line 9 def name @name end |
#root ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/section/block.rb', line 9 def root @root end |
#settings ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/section/block.rb', line 9 def settings @settings end |
#type ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/section/block.rb', line 9 def type @type end |
Class Method Details
.build(hash) ⇒ Object
class methods ##
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/maglev/section/block.rb', line 23 def self.build(hash) attributes = hash.slice('name', 'type', 'accept', 'root', 'limit') attributes['root'] = true if attributes['root'].nil? attributes['limit'] = -1 if attributes['limit'].nil? new( attributes.merge( settings: Maglev::Section::Setting.build_many(hash['settings']) ) ) end |
.build_many(list) ⇒ Object
35 36 37 38 39 |
# File 'app/models/maglev/section/block.rb', line 35 def self.build_many(list) return [] if list.blank? list.map { |hash| build(hash) } end |
Instance Method Details
#root? ⇒ Boolean
methods
17 18 19 |
# File 'app/models/maglev/section/block.rb', line 17 def root? !!root end |