Class: Locomotive::Wagon::EditableElementDecorator

Inherits:
Steam::Decorators::TemplateDecorator
  • Object
show all
Includes:
PersistAssetsConcern, ToHashConcern
Defined in:
lib/locomotive/wagon/decorators/editable_element_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) ⇒ EditableElementDecorator

Returns a new instance of EditableElementDecorator.



11
12
13
14
# File 'lib/locomotive/wagon/decorators/editable_element_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/editable_element_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/editable_element_decorator.rb', line 16

def __attributes__
  %i(block slug content)
end

#contentObject



20
21
22
23
24
25
26
27
# File 'lib/locomotive/wagon/decorators/editable_element_decorator.rb', line 20

def content
  case value = super
  when %r(^/samples/)
    asset_io(value)
  else
    replace_with_content_assets!(value)
  end
end