Class: Locomotive::Wagon::SnippetDecorator

Inherits:
Steam::Decorators::TemplateDecorator
  • Object
show all
Includes:
PersistAssetsConcern, ToHashConcern
Defined in:
lib/locomotive/wagon/decorators/snippet_decorator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PersistAssetsConcern

#asset_io, #replace_with_content_assets!, #replace_with_content_assets_in_hash!

Methods included from ToHashConcern

#prepare_value_for_hash, #to_hash

Constructor Details

#initialize(object, locale = nil, content_assets_pusher) ⇒ SnippetDecorator

Returns a new instance of SnippetDecorator.



11
12
13
14
# File 'lib/locomotive/wagon/decorators/snippet_decorator.rb', line 11

def initialize(object, locale = nil, content_assets_pusher)
  self.__content_assets_pusher__ = content_assets_pusher
  super(object, locale, nil)
end

Instance Attribute Details

#__content_assets_pusher__Object

Returns the value of attribute content_assets_pusher.



9
10
11
# File 'lib/locomotive/wagon/decorators/snippet_decorator.rb', line 9

def __content_assets_pusher__
  @__content_assets_pusher__
end

Instance Method Details

#__attributes__Object



16
17
18
# File 'lib/locomotive/wagon/decorators/snippet_decorator.rb', line 16

def __attributes__
  %i(name slug template)
end

#idObject



20
21
22
# File 'lib/locomotive/wagon/decorators/snippet_decorator.rb', line 20

def id
  slug
end

#templateObject



24
25
26
27
28
29
30
31
32
# File 'lib/locomotive/wagon/decorators/snippet_decorator.rb', line 24

def template
  {}.tap do |translations|
    __getobj__.template_path.translations.each do |locale, _|
      __with_locale__(locale) do
        translations[locale] = replace_with_content_assets!(self.liquid_source)
      end
    end
  end
end