Class: SmsFactor::SmsResponse
- Inherits:
-
Object
- Object
- SmsFactor::SmsResponse
- Defined in:
- lib/sms_factor/sms_response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ SmsResponse
constructor
A new instance of SmsResponse.
- #message ⇒ Object
- #method_missing(m, *args, &block) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ SmsResponse
Returns a new instance of SmsResponse.
4 5 6 |
# File 'lib/sms_factor/sms_response.rb', line 4 def initialize(response) @response = JSON.parse(response) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
16 17 18 19 |
# File 'lib/sms_factor/sms_response.rb', line 16 def method_missing(m, *args, &block) super unless @response.keys.include?(m.to_s) @response[m.to_s] end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
2 3 4 |
# File 'lib/sms_factor/sms_response.rb', line 2 def response @response end |
Instance Method Details
#message ⇒ Object
12 13 14 |
# File 'lib/sms_factor/sms_response.rb', line 12 def @response['message'] end |
#success? ⇒ Boolean
8 9 10 |
# File 'lib/sms_factor/sms_response.rb', line 8 def success? @response['status'] == 1 end |