Class: ApiBee::Adapters::Hash
- Inherits:
-
Object
- Object
- ApiBee::Adapters::Hash
- Defined in:
- lib/api_bee/adapters/hash.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #get(href, opts = {}) ⇒ Object
- #get_one(href, id) ⇒ Object
-
#initialize(data, args = {}) ⇒ Hash
constructor
A new instance of Hash.
Constructor Details
#initialize(data, args = {}) ⇒ Hash
Returns a new instance of Hash.
9 10 11 12 13 14 |
# File 'lib/api_bee/adapters/hash.rb', line 9 def initialize(data, args = {}) @data = data @config = { :uid_field => :id }.merge(args) end |
Instance Attribute Details
#data ⇒ Object (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
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/api_bee/adapters/hash.rb', line 16 def get(href, opts = {}) segments = parse_href(href) segments.inject(deep_clone_of(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 end |
#get_one(href, id) ⇒ Object
30 31 32 |
# File 'lib/api_bee/adapters/hash.rb', line 30 def get_one(href, id) get("#{href}/#{id}") end |