Module: Ohmage::API::Clazz

Included in:
Ohmage::API
Defined in:
lib/ohmage/clazz.rb

Instance Method Summary collapse

Instance Method Details

#class_create(params = {}) ⇒ Object



19
20
21
22
23
# File 'lib/ohmage/clazz.rb', line 19

def class_create(params = {})
  request = Ohmage::Request.new(self, :post, 'class/create', params)
  request.perform
  class_read(class_urn_list: params[:class_urn])
end

#class_delete(params = {}) ⇒ Object



25
26
27
28
# File 'lib/ohmage/clazz.rb', line 25

def class_delete(params = {})
  request = Ohmage::Request.new(self, :post, 'class/delete', params)
  request.perform
end

#class_read(params = {}) ⇒ Object

ohmage class/read call



9
10
11
12
13
14
15
16
17
# File 'lib/ohmage/clazz.rb', line 9

def class_read(params = {})
  request = Ohmage::Request.new(self, :post, 'class/read', params)
  # TODO: make a utility to abstract creation of array of base objects
  t = []
  request.perform[:data].each do |k, v|
    t << Ohmage::Clazz.new(k => v)
  end
  t
end

#class_search(params = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/ohmage/clazz.rb', line 36

def class_search(params = {})
  request = Ohmage::Request.new(self, :post, 'class/search', params)
  # TODO: make a utility to abstract creation of array of base objects
  t = []
  request.perform[:data].each do |k, v|
    t << Ohmage::Clazz.new(k => v)
  end
  t
end

#class_update(params = {}) ⇒ Object



30
31
32
33
34
# File 'lib/ohmage/clazz.rb', line 30

def class_update(params = {})
  request = Ohmage::Request.new(self, :post, 'class/update', params)
  request.perform
  class_read(class_urn_list: params[:class_urn])
end