Class: KeyPayAPI::Resource
- Inherits:
-
Object
- Object
- KeyPayAPI::Resource
- Defined in:
- lib/keypay_api/resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(client, data) ⇒ Resource
constructor
A new instance of Resource.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
Constructor Details
#initialize(client, data) ⇒ Resource
Returns a new instance of Resource.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/keypay_api/resource.rb', line 5 def initialize(client, data) data = {} unless data.is_a?(Hash) @client = client data = data.with_indifferent_access @data = OpenStruct.new(data.with_indifferent_access) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/keypay_api/resource.rb', line 16 def method_missing(method_sym, *arguments, &block) if @data.respond_to?(method_sym) @data.send(method_sym) else super end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/keypay_api/resource.rb', line 3 def data @data end |