Class: SparkApi::OptionsHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/spark_api/options_hash.rb

Overview

Used for API client options that accept string keys instead of symbols – turns all symbol keys into a string for consistancy, allowing applications using the client to pass in parameters as symbols or strings.

Instance Method Summary collapse

Constructor Details

#initialize(from_hash = {}) ⇒ OptionsHash

Returns a new instance of OptionsHash.



6
7
8
9
10
11
12
13
14
15
# File 'lib/spark_api/options_hash.rb', line 6

def initialize(from_hash={})
  from_hash.keys.each do |k|
    if k.is_a?(Symbol)
      self[k.to_s] = from_hash[k] 
    else
      self[k] = from_hash[k] 
    end
  end
  self
end