Class: Typhoid::Builder
- Inherits:
-
Object
- Object
- Typhoid::Builder
- Defined in:
- lib/typhoid/builder.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#parsed_body ⇒ Object
readonly
Returns the value of attribute parsed_body.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(klass, response) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(klass, response) ⇒ Builder
Returns a new instance of Builder.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/typhoid/builder.rb', line 13 def initialize(klass, response) @klass = klass @response = response @body = response.body begin @parsed_body = parser.call body rescue StandardError, ReadError => e @parsed_body = {} @exception = e end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/typhoid/builder.rb', line 5 def body @body end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
7 8 9 |
# File 'lib/typhoid/builder.rb', line 7 def exception @exception end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/typhoid/builder.rb', line 3 def klass @klass end |
#parsed_body ⇒ Object (readonly)
Returns the value of attribute parsed_body.
6 7 8 |
# File 'lib/typhoid/builder.rb', line 6 def parsed_body @parsed_body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/typhoid/builder.rb', line 4 def response @response end |
Class Method Details
.call(klass, response) ⇒ Object
9 10 11 |
# File 'lib/typhoid/builder.rb', line 9 def self.call(klass, response) new(klass, response).build end |
Instance Method Details
#build ⇒ Object
25 26 27 |
# File 'lib/typhoid/builder.rb', line 25 def build array? ? build_array : build_single end |