Methods

Class Public methods

new(column_indexes, row)

📝 Source code
# File activerecord/lib/active_record/result.rb, line 45
def initialize(column_indexes, row)
  @column_indexes = column_indexes
  @row = row
end
🔎 See on GitHub

Instance Public methods

==(other)

📝 Source code
# File activerecord/lib/active_record/result.rb, line 63
def ==(other)
  if other.is_a?(Hash)
    to_hash == other
  else
    super
  end
end
🔎 See on GitHub

[](column)

📝 Source code
# File activerecord/lib/active_record/result.rb, line 85
def [](column)
  if index = @column_indexes[column]
    @row[index]
  end
end
🔎 See on GitHub

each_key(&block)

📝 Source code
# File activerecord/lib/active_record/result.rb, line 55
def each_key(&block)
  @column_indexes.each_key(&block)
end
🔎 See on GitHub

fetch(column)

📝 Source code
# File activerecord/lib/active_record/result.rb, line 75
def fetch(column)
  if index = @column_indexes[column]
    @row[index]
  elsif block_given?
    yield
  else
    raise KeyError, "key not found: #{column.inspect}"
  end
end
🔎 See on GitHub

key?(column)

📝 Source code
# File activerecord/lib/active_record/result.rb, line 71
def key?(column)
  @column_indexes.key?(column)
end
🔎 See on GitHub

keys()

📝 Source code
# File activerecord/lib/active_record/result.rb, line 59
def keys
  @column_indexes.keys
end
🔎 See on GitHub

length()

Alias for: size.

size()

Also aliased as: length.

📝 Source code
# File activerecord/lib/active_record/result.rb, line 50
def size
  @column_indexes.size
end
🔎 See on GitHub

to_h()

Also aliased as: to_hash.

📝 Source code
# File activerecord/lib/active_record/result.rb, line 91
def to_h
  @column_indexes.transform_values { |index| @row[index] }
end
🔎 See on GitHub

to_hash()

Alias for: to_h.