Class: Conduit::Core::Parser
- Inherits:
-
Object
- Object
- Conduit::Core::Parser
- Extended by:
- Forwardable
- Defined in:
- lib/conduit/core/parser.rb
Class Method Summary collapse
-
.attribute(attr_name, &block) ⇒ Object
Define an attribute that will be publically exposed when dealing with conduit responses.
-
.attributes ⇒ Object
Storage array for all attributes.
Instance Method Summary collapse
-
#response_errors ⇒ Object
Default response error container.
-
#response_status ⇒ Object
Default response status.
-
#serializable_hash ⇒ Object
Returns a hash representation of each attribute defined in a parser and its value.
Class Method Details
.attribute(attr_name, &block) ⇒ Object
Define an attribute that will be publically exposed when dealing with conduit responses.
20 21 22 23 |
# File 'lib/conduit/core/parser.rb', line 20 def attribute(attr_name, &block) attributes << attr_name define_method(attr_name, &block) end |
.attributes ⇒ Object
Storage array for all attributes
27 28 29 |
# File 'lib/conduit/core/parser.rb', line 27 def attributes @attributes ||= Set.new end |
Instance Method Details
#response_errors ⇒ Object
Default response error container. Should be overwritten by parser implementation.
54 55 56 |
# File 'lib/conduit/core/parser.rb', line 54 def response_errors raise NoMethodError, 'Please define response_errors in your parser.' end |
#response_status ⇒ Object
Default response status. Should be overwritten by parser implementation.
47 48 49 |
# File 'lib/conduit/core/parser.rb', line 47 def response_status raise NoMethodError, 'Please define response_status in your parser.' end |
#serializable_hash ⇒ Object
Returns a hash representation of each attribute defined in a parser and its value.
38 39 40 41 42 |
# File 'lib/conduit/core/parser.rb', line 38 def serializable_hash attributes.inject({}) do |hash, attribute| hash.tap { |h| h[attribute] = send(attribute) } end end |