Sha256: 62f831a05e0bb5e19b4cf6602db077a26e9fc9a96c37a3ebe49769e52a1a3c17
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 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.send 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 unless from_entity_id.nil? edge.fromEntityType = from_entity_type unless from_entity_type.nil? edge.toEntityId = to_entity_id 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.0 | lib/rebat/selector.rb |