Class: Representable::Binding
- Inherits:
-
Object
- Object
- Representable::Binding
- Extended by:
- Uber::Delegates
- Includes:
- Deprecatable, EvaluateOption, Factories
- Defined in:
- lib/representable/binding.rb
Overview
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.
Direct Known Subclasses
Defined Under Namespace
Modules: Collection, Deprecatable, EvaluateOption, Factories Classes: FragmentNotFound, Map
Instance Attribute Summary collapse
-
#cached_representer ⇒ Object
Returns the value of attribute cached_representer.
-
#getter ⇒ Object
readonly
Returns the value of attribute getter.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#setter ⇒ Object
readonly
Returns the value of attribute setter.
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #default_for(value) ⇒ Object
-
#initialize(definition) ⇒ Binding
constructor
A new instance of Binding.
- #skipable_empty_value?(value) ⇒ Boolean
Methods included from Factories
#collect_for, #default_parse_fragment_functions, #default_parse_init_functions, #default_post_functions, #default_render_fragment_functions, #default_render_init_functions, #parse_functions, #pipeline_for, #render_functions
Methods included from EvaluateOption
Methods included from Deprecatable
#compile_fragment, #uncompile_fragment
Constructor Details
#initialize(definition) ⇒ Binding
Returns a new instance of Binding.
31 32 33 34 35 36 37 38 |
# 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 |
Instance Attribute Details
#cached_representer ⇒ Object
Returns the value of attribute cached_representer.
83 84 85 |
# File 'lib/representable/binding.rb', line 83 def cached_representer @cached_representer end |
#getter ⇒ Object (readonly)
Returns the value of attribute getter.
40 41 42 |
# File 'lib/representable/binding.rb', line 40 def getter @getter end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
40 41 42 |
# File 'lib/representable/binding.rb', line 40 def name @name end |
#setter ⇒ Object (readonly)
Returns the value of attribute setter.
40 41 42 |
# File 'lib/representable/binding.rb', line 40 def setter @setter end |
Class Method Details
.build(definition) ⇒ Object
27 28 29 |
# File 'lib/representable/binding.rb', line 27 def self.build(definition) build_for(definition) end |
Instance Method Details
#[](name) ⇒ Object
69 70 71 |
# File 'lib/representable/binding.rb', line 69 def [](name) @definition[name] end |
#default_for(value) ⇒ Object
77 78 79 80 81 |
# File 'lib/representable/binding.rb', line 77 def default_for(value) return self[:default] if skipable_empty_value?(value) value end |
#skipable_empty_value?(value) ⇒ Boolean
73 74 75 |
# File 'lib/representable/binding.rb', line 73 def skipable_empty_value?(value) value.nil? and !(self[:render_nil]) end |