Class: Maglev::Theme::SectionCategory

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/maglev/theme/section_category.rb

Overview

rubocop:disable Style/ClassAndModuleChildren

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#idObject

attributes ##



9
10
11
# File 'app/models/maglev/theme/section_category.rb', line 9

def id
  @id
end

#nameObject

attributes ##



9
10
11
# File 'app/models/maglev/theme/section_category.rb', line 9

def name
  @name
end

Class Method Details

.build(hash) ⇒ Object

class methods ##



13
14
15
16
17
# File 'app/models/maglev/theme/section_category.rb', line 13

def self.build(hash)
  attributes = hash.slice('name', 'id')
  attributes['id'] ||= attributes['name'].parameterize(separator: '_')
  new(attributes)
end

.build_many(list) ⇒ Object



19
20
21
# File 'app/models/maglev/theme/section_category.rb', line 19

def self.build_many(list)
  (list || []).map { |hash| build(hash) }
end