module Groupy::GroupyServerSupport

Public Instance Methods

delete_entity(params) click to toggle source
# File lib/rugroupy/server.rb, line 34
def delete_entity(params)
  e_json = get_entity_json(params)
  e = Groupy::Entity.new(mongo, e_json['name'], e_json['id'], create = create)
  e.delete
end
get_entity(params, create = false) click to toggle source
# File lib/rugroupy/server.rb, line 18
def get_entity(params, create = false)
  e_json = get_entity_json(params)
  e = Groupy::Entity.new(mongo, e_json['name'], e_json['id'], create)
  e.get
end
get_entity_json(params) click to toggle source
# File lib/rugroupy/server.rb, line 24
def get_entity_json(params)
  JSON.parse(params[:entity])
end
get_entity_similiar(params) click to toggle source
# File lib/rugroupy/server.rb, line 28
def get_entity_similiar(params)
  e_json = get_entity_json(params)
  e = Groupy::Entity.new(mongo, e_json['name'], e_json['id'], create = false)
  e.similiar(e_json['tag'], e_json['skip'], e_json['limit'], e_json['reverse'])
end
group_entities(params) click to toggle source
# File lib/rugroupy/server.rb, line 49
def group_entities(params)
  e_json = get_entity_json(params)
  g = Groupy::EntityGrouper.new(mongo, e_json['name'])
  options = { includeFunction: e_json['include_function'],
              scoreFunction: e_json['score_function'],
              dynamicTagFunction: e_json['dynamic_tag_function'] }
  g.group(options)
end
similiar_entities(params) click to toggle source
# File lib/rugroupy/server.rb, line 58
def similiar_entities(params)
  e_json = get_entity_json(params)
  g = Groupy::EntityGrouper.new(mongo, e_json['name'])
  g.similiar(e_json['tag'], e_json['skip'], e_json['limit'], e_json['reverse'])
end
tag_entity(params, create = true) click to toggle source
# File lib/rugroupy/server.rb, line 40
def tag_entity(params, create = true)
  e_json = get_entity_json(params)
  e = Groupy::Entity.new(mongo, e_json['name'], e_json['id'], create = create)
  e_json['tags'].each_pair do |name, value|
    create ? e.tag(name, value) : e.untag(name, value)
  end
  e.get
end