Class: CostAgent::Base
- Inherits:
-
Object
- Object
- CostAgent::Base
- Defined in:
- lib/costagent.rb
Overview
This provides shared functionality for all of the wrapped FA data types
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(data = {}) ⇒ Base
constructor
A new instance of Base.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 16 |
# File 'lib/costagent.rb', line 13 def initialize(data = {}) @data = {} data.keys.each { |key| @data[key.to_s] = data[key] } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/costagent.rb', line 18 def method_missing(name, *args) key = name.to_s if key[key.length - 1] == "=" @data[key[0...key.length - 1]] = args.first end @data[key] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
11 12 13 |
# File 'lib/costagent.rb', line 11 def data @data end |
Instance Method Details
#id ⇒ Object
26 27 28 |
# File 'lib/costagent.rb', line 26 def id @data["id"] end |