Module: Alchemy::Content::Factory
- Extended by:
- ActiveSupport::Concern
- Included in:
- Alchemy::Content
- Defined in:
- app/models/alchemy/content/factory.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#build_essence(attributes = {}) ⇒ Object
Build essence from definition.
-
#create_essence!(attrs = {}) ⇒ Object
Creates essence from definition.
-
#definition ⇒ Object
Returns the definition hash from
elements.yml
file.
Instance Method Details
#build_essence(attributes = {}) ⇒ Object
Build essence from definition.
If an optional type is passed, this type of essence gets created.
119 120 121 122 123 |
# File 'app/models/alchemy/content/factory.rb', line 119 def build_essence(attributes = {}) self.essence = essence_class.new( { content: self, ingredient: default_value }.merge(attributes) ) end |
#create_essence!(attrs = {}) ⇒ Object
Creates essence from definition.
If an optional type is passed, this type of essence gets created.
129 130 131 132 |
# File 'app/models/alchemy/content/factory.rb', line 129 def create_essence!(attrs = {}) build_essence(attrs).save! save! end |
#definition ⇒ Object
Returns the definition hash from elements.yml
file.
107 108 109 110 111 112 113 |
# File 'app/models/alchemy/content/factory.rb', line 107 def definition if element.blank? log_warning "Content with id #{id} is missing its Element." return {} end element.content_definition_for(name) || {} end |