Class: Semistatic::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Semistatic::Page
- Defined in:
- app/models/semistatic/page.rb
Class Method Summary collapse
-
.factory(template_name, options) ⇒ Object
Factory a page from the config Creates the attributes required by the config.
Instance Method Summary collapse
-
#part(name) ⇒ Object
get part by its name param.
Class Method Details
.factory(template_name, options) ⇒ Object
Factory a page from the config
Creates the attributes required by the config
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/semistatic/page.rb', line 27 def self.factory(template_name, ) page = new(template_name: template_name) = HashWithIndifferentAccess.new() [:parts].each do |name, attributes| part = page.parts.build({ name: name }) part. = attributes end page.save(validate: false) page end |
Instance Method Details
#part(name) ⇒ Object
get part by its name param
18 19 20 |
# File 'app/models/semistatic/page.rb', line 18 def part(name) parts.select {|p| p.name.downcase == name.to_s.downcase }.first end |