Class: Locomotive::Steam::Liquid::Drops::SectionContentProxy

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/locomotive/steam/liquid/drops/section_content_proxy.rb

Overview

Represent the content of a section or a block This abstraction is required to handle content manipulation based on field setting type (url for instance).

Instance Method Summary collapse

Constructor Details

#initialize(content, settings) ⇒ SectionContentProxy

Returns a new instance of SectionContentProxy.



11
12
13
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 11

def initialize(content, settings)
  @content, @settings = content, settings
end

Instance Method Details

#liquid_method_missing(name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 15

def liquid_method_missing(name)
  value = @content[name.to_s]

  return nil if value.blank?

  case type_of(name)
  when 'url'          then SectionUrlField.new(*url_finder.url_for(value))
  when 'image_picker' then SectionImagePickerField.new(value)
  when 'integer'      then value.to_i
  when 'text'         then url_finder.decode_urls_for(value)
  else value
  end
end