Class: Makasi::AsariClient

Inherits:
Object
  • Object
show all
Defined in:
lib/makasi/asari_client.rb

Instance Method Summary collapse

Instance Method Details

#add_item(id, fields) ⇒ Object



3
4
5
# File 'lib/makasi/asari_client.rb', line 3

def add_item(id, fields)
  asari.add_item(hash(id), fields)
end

#remove_allObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/makasi/asari_client.rb', line 20

def remove_all
  loop do
    items = search("lolzcat|-lolzcat")
    break if items.empty?
    items.each do |id, item|
      asari.remove_item(id)
      Rails.logger.debug "Makasi::AsariClient: item ##{id} has been removed"
    end
  end
end

#remove_item(id) ⇒ Object



7
8
9
# File 'lib/makasi/asari_client.rb', line 7

def remove_item(id)
  asari.remove_item(hash(id))
end

#search(query, params = {}) ⇒ Object



11
12
13
# File 'lib/makasi/asari_client.rb', line 11

def search(query, params={})
  asari.search(query, params)
end

#search_resource_ids(query, resource_type) ⇒ Object



15
16
17
18
# File 'lib/makasi/asari_client.rb', line 15

def search_resource_ids(query, resource_type)
  results = search(query, filter: {and: {resource_type: resource_type}})
  results.map{ |id, r| r["resource_id"]}
end