Class: ActiveApi::Field
- Inherits:
-
Object
- Object
- ActiveApi::Field
- Defined in:
- lib/active_api/field.rb
Instance Attribute Summary collapse
-
#choice ⇒ Object
readonly
Returns the value of attribute choice.
-
#field_type ⇒ Object
readonly
Returns the value of attribute field_type.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Field
constructor
A new instance of Field.
- #name_for(object) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Field
Returns a new instance of Field.
5 6 7 8 9 10 11 12 |
# File 'lib/active_api/field.rb', line 5 def initialize( = {}) @type = [:type] @name = [:name] @klass = [:klass] @value = [:value] @choice = [:choice] @field_type = [:field_type] || :element end |
Instance Attribute Details
#choice ⇒ Object (readonly)
Returns the value of attribute choice.
3 4 5 |
# File 'lib/active_api/field.rb', line 3 def choice @choice end |
#field_type ⇒ Object (readonly)
Returns the value of attribute field_type.
3 4 5 |
# File 'lib/active_api/field.rb', line 3 def field_type @field_type end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/active_api/field.rb', line 3 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/active_api/field.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/active_api/field.rb', line 3 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/active_api/field.rb', line 3 def value @value end |
Instance Method Details
#name_for(object) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/active_api/field.rb', line 14 def name_for(object) if choice value = object.send(name) return nil if value.nil? return choice[value.class.to_s] else name end end |