Module: WeBee::RestResource::ClassMethods

Defined in:
lib/webee.rb

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/webee.rb', line 42

def all(options = {})
  col = []
  doc = Nokogiri.parse(RestClient.get(Api.url + "#{@resource_path}"))
  pages = doc.search('//totalSize').text.to_i / 25
  pages = 1 if pages == 0
  1.upto(pages) do |p|
    doc.search("//#{@resource_name}").each do |node|
      col << self.parse(node.to_s)
    end
  end
  col
end

#find(id) ⇒ Object



38
39
40
# File 'lib/webee.rb', line 38

def find(id)
  self.parse(RestClient.get(Api.url + "#{@resource_path}/#{id}"))
end

#resource_name(name) ⇒ Object



59
60
61
# File 'lib/webee.rb', line 59

def resource_name(name)
  @resource_name = name
end

#resource_path(path) ⇒ Object



55
56
57
# File 'lib/webee.rb', line 55

def resource_path(path)
  @resource_path = path
end