Class: Trilogy::Result

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/trilogy/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#affected_rowsObject (readonly)

Returns the value of attribute affected_rows.



3
4
5
# File 'lib/trilogy/result.rb', line 3

def affected_rows
  @affected_rows
end

#fieldsObject (readonly)

Returns the value of attribute fields.



3
4
5
# File 'lib/trilogy/result.rb', line 3

def fields
  @fields
end

#last_insert_idObject (readonly)

Returns the value of attribute last_insert_id.



3
4
5
# File 'lib/trilogy/result.rb', line 3

def last_insert_id
  @last_insert_id
end

#query_timeObject (readonly)

Returns the value of attribute query_time.



3
4
5
# File 'lib/trilogy/result.rb', line 3

def query_time
  @query_time
end

#rowsObject (readonly)

Returns the value of attribute rows.



3
4
5
# File 'lib/trilogy/result.rb', line 3

def rows
  @rows
end

Instance Method Details

#countObject



5
6
7
# File 'lib/trilogy/result.rb', line 5

def count
  rows.count
end

#each(&bk) ⇒ Object



27
28
29
# File 'lib/trilogy/result.rb', line 27

def each(&bk)
  rows.each(&bk)
end

#each_hashObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/trilogy/result.rb', line 9

def each_hash
  return enum_for(:each_hash) unless block_given?

  rows.each do |row|
    this_row = {}

    idx = 0
    row.each do |col|
      this_row[fields[idx]] = col
      idx += 1
    end

    yield this_row
  end

  self
end