Class: Inflect::Response
- Inherits:
-
Object
- Object
- Inflect::Response
- Defined in:
- lib/inflect/response.rb
Overview
Responsible of encapsulate all the content of the service response
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(content = nil, description = {}) ⇒ Inflect::Response constructor
-
#valid? ⇒ true, false
Validates required attributes for a valid response.
Constructor Details
#initialize(content = nil, description = {}) ⇒ Inflect::Response
15 16 17 18 19 20 |
# File 'lib/inflect/response.rb', line 15 def initialize(content=nil, description={}) @content = content @timestamp = Time.now @errors = {} @attributes = extract_attributes(description) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/inflect/response.rb', line 7 def attributes @attributes end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/inflect/response.rb', line 7 def content @content end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/inflect/response.rb', line 7 def errors @errors end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/inflect/response.rb', line 7 def @timestamp end |
Class Method Details
.attribute_keys ⇒ Object
22 23 24 |
# File 'lib/inflect/response.rb', line 22 def self.attribute_keys @@attribute_keys = [:served_by, :query_words] end |
Instance Method Details
#valid? ⇒ true, false
Validates required attributes for a valid response.
39 40 41 42 43 |
# File 'lib/inflect/response.rb', line 39 def valid? private_methods.grep(/valid_attribute/).collect do |method_name| self.send method_name end.all? end |