Class: SimpleRepresenter::Field
- Inherits:
-
Object
- Object
- SimpleRepresenter::Field
- Defined in:
- lib/simple_representer/field.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call(representer) ⇒ Object
-
#initialize(field, options) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(field, options) ⇒ Field
Returns a new instance of Field.
7 8 9 10 |
# File 'lib/simple_representer/field.rb', line 7 def initialize(field, ) @field = field.to_sym @options = end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
5 6 7 |
# File 'lib/simple_representer/field.rb', line 5 def field @field end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/simple_representer/field.rb', line 5 def @options end |
Instance Method Details
#call(representer) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/simple_representer/field.rb', line 12 def call(representer) return if [:if] && !representer.instance_exec(&[:if]) value = process(representer) value = [:default] if value.nil? value = nested_representer(value) if [:representer] && !value.nil? build_field(value) end |