Class: DatabaseRecorder::PG::RecordedResult

Inherits:
Object
  • Object
show all
Defined in:
lib/database_recorder/pg/recorded_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ RecordedResult

Returns a new instance of RecordedResult.



13
14
15
16
17
# File 'lib/database_recorder/pg/recorded_result.rb', line 13

def initialize(data)
  @count = data[:count]
  @fields = data[:fields]
  @values = data[:values]
end

Instance Attribute Details

#countObject (readonly) Also known as: cmd_tuples, ntuples

Returns the value of attribute count.



6
7
8
# File 'lib/database_recorder/pg/recorded_result.rb', line 6

def count
  @count
end

#fieldsObject (readonly) Also known as: columns

Returns the value of attribute fields.



6
7
8
# File 'lib/database_recorder/pg/recorded_result.rb', line 6

def fields
  @fields
end

#type_mapObject (readonly)

Returns the value of attribute type_map.



6
7
8
# File 'lib/database_recorder/pg/recorded_result.rb', line 6

def type_map
  @type_map
end

#valuesObject (readonly) Also known as: rows

Returns the value of attribute values.



6
7
8
# File 'lib/database_recorder/pg/recorded_result.rb', line 6

def values
  @values
end

Instance Method Details

#clearObject



19
# File 'lib/database_recorder/pg/recorded_result.rb', line 19

def clear; end

#firstObject



21
22
23
# File 'lib/database_recorder/pg/recorded_result.rb', line 21

def first
  to_a.first
end

#fmod(_index) ⇒ Object



25
26
27
# File 'lib/database_recorder/pg/recorded_result.rb', line 25

def fmod(_index)
  -1
end

#ftype(_index) ⇒ Object



29
30
31
# File 'lib/database_recorder/pg/recorded_result.rb', line 29

def ftype(_index)
  20
end

#map_types!(type_map) ⇒ Object



33
34
35
36
# File 'lib/database_recorder/pg/recorded_result.rb', line 33

def map_types!(type_map)
  @type_map = type_map
  self
end

#nfieldsObject



38
39
40
# File 'lib/database_recorder/pg/recorded_result.rb', line 38

def nfields
  fields.size
end

#to_aObject



42
43
44
45
46
# File 'lib/database_recorder/pg/recorded_result.rb', line 42

def to_a
  @to_a ||= values.each_with_object([]) do |value, list|
    list << fields.zip(value).to_h
  end
end