Module: Panda::Finders::FindOne
- Included in:
- Proxy
- Defined in:
- lib/panda/modules/finders.rb
Instance Method Summary collapse
- #find(id) ⇒ Object
- #find_by_path(url, map = {}) ⇒ Object
- #find_object_by_path(url, map = {}) ⇒ Object
Instance Method Details
#find(id) ⇒ Object
11 12 13 14 |
# File 'lib/panda/modules/finders.rb', line 11 def find(id) raise 'find method requires a correct value' if id.nil? || id == '' find_by_path(one_path, {:id => id}) end |
#find_by_path(url, map = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/panda/modules/finders.rb', line 22 def find_by_path(url, map={}) object = find_object_by_path(url, map) kclass = Panda::const_get("#{sti_name}") if object.is_a?(Array) object.map{|o| kclass.new(o)} elsif object['id'] kclass.new(object) else raise APIError.new(object) end end |
#find_object_by_path(url, map = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/panda/modules/finders.rb', line 16 def find_object_by_path(url, map={}) rest_url = create_rest_url(url, map) params = extract_unmapped_variables(url, map) connection.get(rest_url, params) end |