Class: BetfairApiNgRails::Api::Hashalator

Inherits:
Object
  • Object
show all
Includes:
Data::Constants
Defined in:
lib/betfair_api_ng_rails/api/hashalator.rb

Constant Summary

Constants included from Data::Constants

Data::Constants::ATTRS_AS_IS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, for_param = false) ⇒ Hashalator

Returns a new instance of Hashalator.



8
9
10
11
# File 'lib/betfair_api_ng_rails/api/hashalator.rb', line 8

def initialize(object, for_param = false)
  @hashable = object
  @for_param = for_param
end

Instance Attribute Details

#for_paramObject (readonly)

Returns the value of attribute for_param.



6
7
8
# File 'lib/betfair_api_ng_rails/api/hashalator.rb', line 6

def for_param
  @for_param
end

#hashableObject (readonly)

Returns the value of attribute hashable.



6
7
8
# File 'lib/betfair_api_ng_rails/api/hashalator.rb', line 6

def hashable
  @hashable
end

Instance Method Details

#to_hashObject



13
14
15
16
17
18
19
# File 'lib/betfair_api_ng_rails/api/hashalator.rb', line 13

def to_hash
  hashable.inject({}) do |h, (k, v)|
    value = hash_value(v)
    h[hash_key(k)] = value if !value.nil? && value != ""
    h
  end
end