Class: HelloGoodbye::Response
- Inherits:
-
Object
- Object
- HelloGoodbye::Response
- Defined in:
- lib/hello_goodbye/json/response.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#results ⇒ Object
Returns the value of attribute results.
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Response
constructor
A new instance of Response.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 |
# File 'lib/hello_goodbye/json/response.rb', line 5 def initialize(={}) .map do |key,value| self.send("#{key}=".to_sym,value) if self.respond_to?("#{key}=".to_sym) end end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/hello_goodbye/json/response.rb', line 3 def @message end |
#results ⇒ Object
Returns the value of attribute results.
3 4 5 |
# File 'lib/hello_goodbye/json/response.rb', line 3 def results @results end |
#success ⇒ Object
Returns the value of attribute success.
3 4 5 |
# File 'lib/hello_goodbye/json/response.rb', line 3 def success @success end |
Instance Method Details
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/hello_goodbye/json/response.rb', line 23 def to_hash h = { "success" => self.success, "message" => self..to_s } h["results"] = self.results if !self.results.nil? h end |
#to_json ⇒ Object
32 33 34 |
# File 'lib/hello_goodbye/json/response.rb', line 32 def to_json self.to_hash.to_json end |