Module: BetfairApiNgRails::Api::Caching::Helper

Included in:
ResponseCache
Defined in:
lib/betfair_api_ng_rails/api/caching/helper.rb

Instance Method Summary collapse

Instance Method Details

#createsig(body) ⇒ Object



5
6
7
# File 'lib/betfair_api_ng_rails/api/caching/helper.rb', line 5

def createsig(body)
  Digest::MD5.hexdigest sigflat(body)
end

#sigflat(body) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/betfair_api_ng_rails/api/caching/helper.rb', line 9

def sigflat(body)
  res = nil
  if body.class == Hash
    arr = []
    body.each do |key, value|
      arr << "#{sigflat key}=>#{sigflat value}"
    end
    res = arr
  end
  if body.class == Array
    str = ''
    res = body.map do |value|
      sigflat value
    end.sort!.each do |value|
      str << value
    end
  end
  if body.class != String
    res = body.to_s << body.class.to_s
  end
  res || body
end