方法
类公共方法
new(column_indexes, row) 链接
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 45 def initialize(column_indexes, row) @column_indexes = column_indexes @row = row end
实例公共方法
==(other) 链接
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 63 def ==(other) if other.is_a?(Hash) to_hash == other else super end end
[](column) 链接
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 85 def [](column) if index = @column_indexes[column] @row[index] end end
each_key(&block) 链接
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 55 def each_key(&block) @column_indexes.each_key(&block) end
fetch(column) 链接
源: 显示 | 在 GitHub 上
# 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
key?(column) 链接
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 71 def key?(column) @column_indexes.key?(column) end
keys() 链接
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 59 def keys @column_indexes.keys end
size() 链接
也别名为: length
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 50 def size @column_indexes.size end
to_h() 链接
也别名为: to_hash
源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/result.rb, line 91 def to_h @column_indexes.transform_values { |index| @row[index] } end