Class: JSONAPI::Field
Overview
Field is the name of key value pair
Instance Attribute Summary
Attributes inherited from Item
Instance Method Summary collapse
-
#initialize(name, type: String) ⇒ Field
constructor
A new instance of Field.
-
#name ⇒ String
The Field’s name.
- #name=(_) ⇒ Object
-
#to_s ⇒ String
The name of the field.
-
#type ⇒ Object
The type of the field.
- #type=(new_type) ⇒ Object
Methods inherited from Item
Constructor Details
#initialize(name, type: String) ⇒ Field
Returns a new instance of Field.
11 12 13 |
# File 'lib/easy/jsonapi/field.rb', line 11 def initialize(name, type: String) super({ name: name.to_s, type: type }) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JSONAPI::Item
Instance Method Details
#name ⇒ String
Returns The Field’s name.
16 17 18 |
# File 'lib/easy/jsonapi/field.rb', line 16 def name @item[:name] end |
#name=(_) ⇒ Object
22 23 24 |
# File 'lib/easy/jsonapi/field.rb', line 22 def name=(_) raise 'Cannot change the name of a Resource::Field' end |
#to_s ⇒ String
Returns The name of the field.
37 38 39 |
# File 'lib/easy/jsonapi/field.rb', line 37 def to_s name end |
#type ⇒ Object
Returns The type of the field.
27 28 29 |
# File 'lib/easy/jsonapi/field.rb', line 27 def type @item[:type] end |
#type=(new_type) ⇒ Object
32 33 34 |
# File 'lib/easy/jsonapi/field.rb', line 32 def type=(new_type) @item[:type] = new_type end |