Module: Alchemy::Content::Factory

Extended by:
ActiveSupport::Concern
Included in:
Alchemy::Content
Defined in:
app/models/alchemy/content/factory.rb

Overview

Holds everything concerning the building and creating of contents and the related essence object.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#create_essence!(type = nil) ⇒ Object

Creates essence from definition.

If an optional type is passed, this type of essence gets created.



147
148
149
150
# File 'app/models/alchemy/content/factory.rb', line 147

def create_essence!(type = nil)
  self.essence = essence_class(type).create!(prepared_attributes_for_essence)
  save!
end

#definitionObject

Returns the definition hash from elements.yml file.



135
136
137
138
139
140
141
# File 'app/models/alchemy/content/factory.rb', line 135

def definition
  if element.blank?
    log_warning "Content with id #{id} is missing its Element."
    return {}
  end
  element.content_definition_for(name) || {}
end