Class: JSONAPI::Document::Error
- Inherits:
-
NameValuePairCollection
- Object
- Collection
- NameValuePairCollection
- JSONAPI::Document::Error
- Defined in:
- lib/easy/jsonapi/document/error.rb,
lib/easy/jsonapi/document/error/error_member.rb
Overview
An individual errors member in a jsonapi’s document top level ‘errors’ member array
Defined Under Namespace
Classes: ErrorMember
Instance Method Summary collapse
-
#<<(error_mem) ⇒ Object
Another way to call add.
-
#add(error_mem) ⇒ Object
Add a error to the collection using it’s name.
-
#initialize(err_members = []) ⇒ Error
constructor
A new instance of Error.
-
#to_h ⇒ Object
Represent an Error as a hash.
Methods inherited from NameValuePairCollection
Methods inherited from Collection
#[], #[]=, #each, #empty?, #get, #include?, #insert, #keys, #remove, #set, #size, #to_s
Constructor Details
#initialize(err_members = []) ⇒ Error
Returns a new instance of Error.
14 15 16 |
# File 'lib/easy/jsonapi/document/error.rb', line 14 def initialize(err_members = []) super(err_members, item_type: JSONAPI::Document::Error::ErrorMember) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JSONAPI::NameValuePairCollection
Instance Method Details
#<<(error_mem) ⇒ Object
Another way to call add
29 30 31 |
# File 'lib/easy/jsonapi/document/error.rb', line 29 def <<(error_mem) super(error_mem, &:name) end |
#add(error_mem) ⇒ Object
Add a error to the collection using it’s name
23 24 25 |
# File 'lib/easy/jsonapi/document/error.rb', line 23 def add(error_mem) super(error_mem, &:name) end |
#to_h ⇒ Object
Represent an Error as a hash
42 43 44 |
# File 'lib/easy/jsonapi/document/error.rb', line 42 def to_h JSONAPI::Utility.to_h_collection(self) end |