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 description.

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



164
165
166
167
# File 'app/models/alchemy/content/factory.rb', line 164

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

#descriptionObject Also known as: definition

Returns the description hash from elements.yml file.



151
152
153
154
155
156
157
# File 'app/models/alchemy/content/factory.rb', line 151

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