Class: Flock::SimpleOperation

Inherits:
SelectOperation show all
Defined in:
lib/flock/operations/simple_operation.rb

Instance Method Summary collapse

Methods inherited from SelectOperation

#difference, #get_results, #intersect, #operation, #size, #union

Methods included from Mixins::Sizeable

#any?, #empty?

Constructor Details

#initialize(client, query) ⇒ SimpleOperation

Returns a new instance of SimpleOperation.



3
4
5
6
# File 'lib/flock/operations/simple_operation.rb', line 3

def initialize(client, query)
  super(client)
  @term = query
end

Instance Method Details

#edgesObject



8
9
10
11
12
13
14
15
# File 'lib/flock/operations/simple_operation.rb', line 8

def edges
  Flock::Operation.new do |page|
    query = to_thrift_edges
    query.page = page
    result = @service.select_edges(Array(query)).first
    [result.edges, result.next_cursor, result.prev_cursor]
  end
end

#to_thriftObject



17
18
19
20
21
22
23
# File 'lib/flock/operations/simple_operation.rb', line 17

def to_thrift
  operation = Edges::SelectOperation.new
  operation.operation_type = Edges::SelectOperationType::SimpleQuery
  operation.term = @term.to_thrift

  Array(operation)
end

#to_thrift_edgesObject



25
26
27
28
29
# File 'lib/flock/operations/simple_operation.rb', line 25

def to_thrift_edges
  query = Edges::EdgeQuery.new
  query.term = @term.to_thrift
  query
end