Class: ApiBee::Adapters::Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/api_bee/adapters/hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Hash

Returns a new instance of Hash.



9
10
11
# File 'lib/api_bee/adapters/hash.rb', line 9

def initialize(*args)
  @data = args.last
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/api_bee/adapters/hash.rb', line 7

def data
  @data
end

Instance Method Details

#get(href, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/api_bee/adapters/hash.rb', line 13

def get(href, opts = {})
  segments = parse_href(href)
  found = segments.inject(data) do |mem,i|
    case mem
    when ::Hash
      handle_hash_data mem, i, opts
    when ::Array
      handle_array_data mem, i
    else
      mem
    end
  end
  found
end

#get_one(href, id) ⇒ Object



28
29
30
# File 'lib/api_bee/adapters/hash.rb', line 28

def get_one(href, id)
  get("#{href}/#{id}")
end