Module: Panda::Finders::FindOne

Included in:
Cloud, Proxy
Defined in:
lib/panda/modules/finders.rb

Instance Method Summary collapse

Instance Method Details

#find(id) ⇒ Object



6
7
8
# File 'lib/panda/modules/finders.rb', line 6

def find(id)
  find_by_path(one_path, {:id => id})
end

#find_by_path(url, map = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/panda/modules/finders.rb', line 16

def find_by_path(url, map={})
  object = find_object_by_path(url, map)
  kclass = Panda::const_get("#{end_class_name}")

  if object.is_a?(Array)
    object.map{|o| kclass.new(o)}
  elsif object['id']
    kclass.new(object)
  else
    Error.new(object).raise!
  end
end

#find_object_by_path(url, map = {}) ⇒ Object



10
11
12
13
14
# File 'lib/panda/modules/finders.rb', line 10

def find_object_by_path(url, map={})
  full_url = object_url(url, map)
  params = element_params(url, map)
  self.connection.get(full_url, params)
end