Sha256: 06e140fbcac4006bf1e1aff21bb70e4ca5e28e77fea06b81d28d1163ace9d11b

Contents?: true

Size: 695 Bytes

Versions: 102

Compression:

Stored size: 695 Bytes

Contents

module ActiveRecord
  ###
  # This class encapsulates a Result returned from calling +exec_query+ on any
  # database connection adapter. For example:
  #
  #   x = ActiveRecord::Base.connection.exec_query('SELECT * FROM foo')
  #   x # => #<ActiveRecord::Result:0xdeadbeef>
  class Result
    include Enumerable

    attr_reader :columns, :rows

    def initialize(columns, rows)
      @columns   = columns
      @rows      = rows
      @hash_rows = nil
    end

    def each
      hash_rows.each { |row| yield row }
    end

    def to_hash
      hash_rows
    end

    private
    def hash_rows
      @hash_rows ||= @rows.map { |row|
        Hash[@columns.zip(row)]
      }
    end
  end
end

Version data entries

102 entries across 77 versions & 10 rubygems

Version Path
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.12/lib/active_record/result.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
challah-1.0.0.beta vendor/bundle/gems/activerecord-3.2.11/lib/active_record/result.rb
activerecord-3.2.13.rc1 lib/active_record/result.rb
active_mailer-0.0.5 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
active_mailer-0.0.4 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
active_mailer-0.0.3 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/result.rb
activerecord-3.2.12 lib/active_record/result.rb
challah-0.9.1.beta.3 vendor/bundle/gems/activerecord-3.2.11/lib/active_record/result.rb
devise_sociable-0.1.0 vendor/bundle/gems/activerecord-3.2.11/lib/active_record/result.rb
challah-0.9.1.beta vendor/bundle/gems/activerecord-3.2.11/lib/active_record/result.rb
activerecord-3.2.11 lib/active_record/result.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.10/lib/active_record/result.rb
challah-0.9.0 vendor/bundle/gems/activerecord-3.2.9/lib/active_record/result.rb
activerecord-3.2.10 lib/active_record/result.rb
challah-rolls-0.2.0 vendor/bundle/gems/activerecord-3.2.9/lib/active_record/result.rb