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.


126
127
128
129
# File 'app/models/alchemy/content/factory.rb', line 126

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.


114
115
116
117
118
119
120
# File 'app/models/alchemy/content/factory.rb', line 114

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