Class: Qtc::Eds::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/qtc/eds/collection.rb

Direct Known Subclasses

UserCollection, UsergroupCollection

Instance Method Summary collapse

Constructor Details

#initialize(client, path) ⇒ Collection

Initialize EDS collection



10
11
12
13
# File 'lib/qtc/eds/collection.rb', line 10

def initialize(client, path)
  @client = client
  @path = path
end

Instance Method Details

#add_permissions(id, permissions) ⇒ Hash

Add permissions



92
93
94
# File 'lib/qtc/eds/collection.rb', line 92

def add_permissions(id, permissions)
  client.put("#{path}/#{id}/access", permissions)
end

#atomic_operation(id, operation) ⇒ Hash

Atomic operation



40
41
42
# File 'lib/qtc/eds/collection.rb', line 40

def atomic_operation(id, operation)
  client.put("#{path}/#{id}/atomic", operation)
end

#find(params = {}) ⇒ Array<Hash>

Find objects



67
68
69
70
71
72
73
74
75
76
# File 'lib/qtc/eds/collection.rb', line 67

def find(params = {})
  if params[:q] && params[:q].is_a?(Hash)
    params[:q] = params[:q].to_json
  end
  if params[:sort] && !params[:sort].is_a?(String)
    params[:sort] = params[:sort].to_json
  end
  response = client.get("#{path}", params)
  response['results']
end

#find_one(id) ⇒ Hash

Find object by id



58
59
60
# File 'lib/qtc/eds/collection.rb', line 58

def find_one(id)
  client.get("#{path}/#{id}")
end

#insert(object) ⇒ Hash

Insert a new object



20
21
22
# File 'lib/qtc/eds/collection.rb', line 20

def insert(object)
  client.post(path, object)
end

#remove(id) ⇒ Hash

Remove object



49
50
51
# File 'lib/qtc/eds/collection.rb', line 49

def remove(id)
  client.delete("#{path}/#{id}")
end

#remove_permissions(id, permissions) ⇒ Hash

Remove permissions



102
103
104
# File 'lib/qtc/eds/collection.rb', line 102

def remove_permissions(id, permissions)
  client.delete("#{path}/#{id}/access", permissions)
end

#set_permissions(id, permissions) ⇒ Object

Set object permissions



82
83
84
# File 'lib/qtc/eds/collection.rb', line 82

def set_permissions(id, permissions)
  client.post("#{path}/#{id}/access", permissions)
end

#update(id, object) ⇒ Hash

Update object



30
31
32
# File 'lib/qtc/eds/collection.rb', line 30

def update(id, object)
  client.put("#{path}/#{id}", object)
end