Sha256: fb1e2a588f05b7d67b9bb4bd851ea624e7cf11208a180001447634475a939dfd
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
class Rebat::Selector attr_reader :client def initialize(client) @client = client @query_list = [] end def where(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_key) @query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, @client.relations[relation_key], Rebat::Thrift::QueryType::WHERE) return self end def union(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_key) @query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, @client.relations[relation_key], Rebat::Thrift::QueryType::UNION) return self end def intersect(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_key) @query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, @client.relations[relation_key], Rebat::Thrift::QueryType::INTERSECT) return self end def exclude(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_key) @query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, @client.relations[relation_key], Rebat::Thrift::QueryType::EXCLUDE) return self end def entries @client.sendQuery do |client| return client.selectQuery(@query_list) end end private attr_reader :query_list def create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id, qtype) edge = Rebat::Thrift::Edge.new edge.fromEntityId = from_entity_id.to_s unless from_entity_id.nil? edge.fromEntityType = from_entity_type unless from_entity_type.nil? edge.toEntityId = to_entity_id.to_s unless to_entity_id.nil? edge.toEntityType = to_entity_type unless to_entity_type.nil? edge.relationId = relation_id query = Rebat::Thrift::Query.new query.edge = edge query.qtype = qtype return query end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rebat-0.1.4 | lib/rebat/selector.rb |