Module: Locomotive::Concerns::ContentType::EntryTemplate

Extended by:
ActiveSupport::Concern
Included in:
Locomotive::ContentType
Defined in:
app/models/locomotive/concerns/content_type/entry_template.rb

Instance Method Summary collapse

Instance Method Details

#render_entry_template(context) ⇒ Object


16
17
18
19
# File 'app/models/locomotive/concerns/content_type/entry_template.rb', line 16

def render_entry_template(context)
  return nil if entry_template.blank?
  parsed_entry_template.render(context)
end

#steam_repositoriesObject


37
38
39
# File 'app/models/locomotive/concerns/content_type/entry_template.rb', line 37

def steam_repositories
  @steam_repositories ||= Locomotive::Steam::Services.build_instance.repositories
end

#to_steamObject


21
22
23
# File 'app/models/locomotive/concerns/content_type/entry_template.rb', line 21

def to_steam
  @steam_content_type ||= steam_repositories.content_type.build(self.attributes.symbolize_keys)
end

#to_steam_entry(entry) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/locomotive/concerns/content_type/entry_template.rb', line 25

def to_steam_entry(entry)
  entry_attributes = entry.attributes.symbolize_keys

  steam_repositories.content_entry.with(to_steam).build(entry_attributes).tap do |entity|
    # copy error messages
    entry.errors.each do |name, message|
      next if name == :_slug
      entity.errors.add(name, message)
    end
  end
end