class JSONAPI::Field
Field
is the name of key value pair
Public Class Methods
new(name, type: String)
click to toggle source
@param name [String] The name of the field @param type [String | nil] The type of the field
Calls superclass method
JSONAPI::Item::new
# File lib/easy/jsonapi/field.rb, line 11 def initialize(name, type: String) super({ name: name.to_s, type: type }) end
Public Instance Methods
name()
click to toggle source
@return [String] The Field's name
# File lib/easy/jsonapi/field.rb, line 16 def name @item[:name] end
name=(_)
click to toggle source
@raise RunTimeError You shoulddn't be able to update the name of a
Resource::Field
# File lib/easy/jsonapi/field.rb, line 22 def name=(_) raise 'Cannot change the name of a Resource::Field' end
to_s()
click to toggle source
@return [String] The name of the field.
# File lib/easy/jsonapi/field.rb, line 37 def to_s name end
type()
click to toggle source
@return [Object] The type of the field
# File lib/easy/jsonapi/field.rb, line 27 def type @item[:type] end
type=(new_type)
click to toggle source
@param new_type [Object] The new type of field.
# File lib/easy/jsonapi/field.rb, line 32 def type=(new_type) @item[:type] = new_type end