class Representable::Binding
The Binding
provides methods to read/write the fragment for one property.
Actually parsing the fragment from the document happens in Binding#read, everything after that is generic.
Attributes
Public Class Methods
Source
# File lib/representable/binding.rb, line 27 def self.build(definition) build_for(definition) end
Source
# File lib/representable/binding.rb, line 31 def initialize(definition) @definition = definition @name = @definition.name @getter = @definition.getter @setter = @definition.setter setup_exec_context! end
Public Instance Methods
Source
# File lib/representable/binding.rb, line 77 def default_for(value) return self[:default] if skipable_empty_value?(value) value end
Source
# File lib/representable/binding.rb, line 73 def skipable_empty_value?(value) value.nil? and !(self[:render_nil]) end
Private Instance Methods
Source
# File lib/representable/binding.rb, line 96 def exec_context(options) @exec_context.call(options) end
Source
# File lib/representable/binding.rb, line 100 def parse_pipeline(input, options) @parse_pipeline ||= pipeline_for(:parse_pipeline, input, options) { Pipeline[*parse_functions] } end
Source
# File lib/representable/binding.rb, line 104 def render_pipeline(input, options) @render_pipeline ||= pipeline_for(:render_pipeline, input, options) { Pipeline[*render_functions] } end
Source
# File lib/representable/binding.rb, line 90 def setup_exec_context! @exec_context = ->(options) { options[:represented] } unless self[:exec_context] @exec_context = ->(_options) { self } if self[:exec_context] == :binding @exec_context = ->(options) { options[:decorator] } if self[:exec_context] == :decorator end