module Cassie::Statements::Results::Peeking

Public Instance Methods

peeked_result() click to toggle source
# File lib/cassie/statements/execution/results/peeking.rb, line 10
def peeked_result
  return @peeked_result if defined?(@peeked_result)

  @peeked_result = if peeked_row
    each_deserializer.call(peeked_row)
  end
end

Protected Instance Methods

after_initialize(opts={}) click to toggle source
Calls superclass method
# File lib/cassie/statements/execution/results/peeking.rb, line 20
def after_initialize(opts={})
  super
  @limit = opts[:limit]
  extract_peeked_rows_after(limit)
end
extract_peeked_rows_after(limit) click to toggle source
# File lib/cassie/statements/execution/results/peeking.rb, line 26
def extract_peeked_rows_after(limit)
  peeked_count = rows.count - limit
  @peeked_row = case
  when peeked_count == 1
    raw_rows.delete_at(-1)
  when peeked_count <= 0
    nil
  else
    raise "More than one row was peeked at. Please report this Cassie issue: https://github.com/eprothro/cassie/issues."
  end
end
raw_rows() click to toggle source
# File lib/cassie/statements/execution/results/peeking.rb, line 38
def raw_rows
  __getobj__.instance_variable_get(:@rows)
end