Class: JSONAPI::Document::Resource::Attributes::Attribute

Inherits:
NameValuePair show all
Defined in:
lib/easy/jsonapi/document/resource/attributes/attribute.rb

Overview

An individual attribute in a JSON:API Attributes object

Instance Attribute Summary collapse

Attributes inherited from Item

#item

Instance Method Summary collapse

Methods inherited from NameValuePair

#name, #name=, #to_h, #to_s, #value, #value=

Methods inherited from Item

#to_h, #to_s

Constructor Details

#initialize(name, value, type: String) ⇒ Attribute

Returns a new instance of Attribute.

Parameters:

  • name (String)

    The name of an attribute

  • value (String)

    The value of an attribute

  • type (Any) (defaults to: String)

    The type of an attribute value



20
21
22
23
# File 'lib/easy/jsonapi/document/resource/attributes/attribute.rb', line 20

def initialize(name, value, type: String)
  @field = JSONAPI::Field.new(name, type: type)
  super(name, value)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JSONAPI::Item

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



15
16
17
# File 'lib/easy/jsonapi/document/resource/attributes/attribute.rb', line 15

def field
  @field
end