Class: Refinery::Widgets::Template
- Inherits:
-
Core::BaseModel
- Object
- Core::BaseModel
- Refinery::Widgets::Template
- Defined in:
- app/models/refinery/widgets/template.rb
Constant Summary collapse
- PartNames =
Refinery::Pages.config[:default_parts]
- Parts =
PartNames.map(&:underscore)
Class Method Summary collapse
Instance Method Summary collapse
- #synchronize_template_parts ⇒ Object
- #template_part(name) ⇒ Object
- #unlocked_template_parts ⇒ Object
- #widgets ⇒ Object
Class Method Details
.part_names ⇒ Object
20 21 22 |
# File 'app/models/refinery/widgets/template.rb', line 20 def self.part_names PartNames end |
.parts ⇒ Object
24 25 26 |
# File 'app/models/refinery/widgets/template.rb', line 24 def self.parts Parts end |
Instance Method Details
#synchronize_template_parts ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/models/refinery/widgets/template.rb', line 28 def synchronize_template_parts pages.each do |p| template_parts.each do |tp| tp.(p) end end end |
#template_part(name) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'app/models/refinery/widgets/template.rb', line 40 def template_part(name) if template_parts.find{|tp| tp.name == name } template_parts.find{|tp| tp.name == name } elsif template_parts.where(name: name).any? template_parts.where(name: name).first else self.template_parts.build(name: name, locked: '0') end end |
#unlocked_template_parts ⇒ Object
36 37 38 |
# File 'app/models/refinery/widgets/template.rb', line 36 def unlocked_template_parts template_parts.reject(&:locked?) end |
#widgets ⇒ Object
50 51 52 |
# File 'app/models/refinery/widgets/template.rb', line 50 def template_parts.collect(&:widgets).flatten end |