Class: OandaAPI::ResourceBase
- Inherits:
-
Object
- Object
- OandaAPI::ResourceBase
- Defined in:
- lib/oanda_api/resource_base.rb
Overview
Base class for all Resources.
Direct Known Subclasses
OandaAPI::Resource::Account, OandaAPI::Resource::Candle, OandaAPI::Resource::Instrument, OandaAPI::Resource::Order, OandaAPI::Resource::Order::OrderOpened, OandaAPI::Resource::Order::TradeOpened, OandaAPI::Resource::Order::TradeReduced, OandaAPI::Resource::Position, OandaAPI::Resource::Price, OandaAPI::Resource::Trade, OandaAPI::Resource::Transaction, OandaAPI::Resource::Transaction::TradeOpened, OandaAPI::Resource::Transaction::TradeReduced
Instance Attribute Summary collapse
-
#location ⇒ String
The +location+ header if one is returned in an API response.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ ResourceBase
constructor
A new instance of ResourceBase.
Constructor Details
#initialize(attributes = {}) ⇒ ResourceBase
Returns a new instance of ResourceBase.
17 18 19 20 |
# File 'lib/oanda_api/resource_base.rb', line 17 def initialize(attributes = {}) initialize_attributes Utils.rubyize_keys(attributes.dup) @location = attributes.location if attributes.respond_to? :location end |
Instance Attribute Details
#location ⇒ String
Returns the +location+ header if one is returned in an API response.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/oanda_api/resource_base.rb', line 11 class ResourceBase attr_accessor :location # @param [Hash] attributes collection of resource attributes. See the # {http://developer.oanda.com/rest-live/development-guide/ Oanda Developer Guide} # for documentation about resource attributes. def initialize(attributes = {}) initialize_attributes Utils.rubyize_keys(attributes.dup) @location = attributes.location if attributes.respond_to? :location end private # @private # Initializes attributes. # # @param [Hash] attributes collection of resource attributes. # @return [void] def initialize_attributes(attributes) attributes.each do |key, value| send("#{key}=", value) if respond_to? key end end end |