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 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

#themeObject

attributes ##



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

def theme
  @theme
end

Class Method Details

.build(hash) ⇒ Object

class methods ##



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

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

.build_many(list) ⇒ Object



24
25
26
# File 'app/models/maglev/theme/section_category.rb', line 24

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

Instance Method Details

#human_nameObject

methods ##



12
13
14
# File 'app/models/maglev/theme/section_category.rb', line 12

def human_name
  I18n.t("maglev.themes.#{theme.id}.categories.#{id}.name", default: name.humanize)
end