Class: Rufus::Edo::TableResultSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rufus/edo/tabcore.rb

Overview

The thing queries return

Instance Method Summary collapse

Constructor Details

#initialize(table, primary_keys, query_opts) ⇒ TableResultSet

Returns a new instance of TableResultSet.



518
519
520
521
522
523
# File 'lib/rufus/edo/tabcore.rb', line 518

def initialize (table, primary_keys, query_opts)

  @table = table
  @keys = primary_keys
  @opts = query_opts
end

Instance Method Details

#eachObject

The classical each



536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/rufus/edo/tabcore.rb', line 536

def each

  @keys.each do |pk|
    if @opts[:pk_only]
      yield(pk)
    else
      val = @table[pk]
      val[:pk] = pk unless @opts[:no_pk]
      yield(val)
    end
  end
end

#freeObject Also known as: close, destroy

Frees this query (the underlying Tokyo Cabinet list structure)



558
559
560
561
# File 'lib/rufus/edo/tabcore.rb', line 558

def free

  # nothing to do, kept for similarity with Rufus::Tokyo
end

#sizeObject Also known as: length

Returns the count of element in this result set



527
528
529
530
# File 'lib/rufus/edo/tabcore.rb', line 527

def size

  @keys.size
end

#to_aObject

Returns an array of hashes



551
552
553
554
# File 'lib/rufus/edo/tabcore.rb', line 551

def to_a

  self.collect { |m| m }
end