Sha256: e441a592ef90b60114009364cd14af9ef3308a0da7499230fefcf09b8451c47f
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module ActiveRecord module Collections module Collectable module Model def collection(*criteria) ActiveRecord::Collection.new(self, *criteria) end alias_method :collect, :collection end module Relation def collection # do this with a hash so that we don't cause the relation query to execute ActiveRecord::Collection.from_hash({ klass: klass, select: select_values, distinct: distinct_value, joins: joins_values, references: references_values, includes: includes_values, where: where_values.map { |v| v.is_a?(String) ? v : v.to_sql }, order: order_values.map { |v| v.is_a?(String) ? v : v.to_sql }, bind: bind_values.map { |b| {name: b.first.name, value: b.last} }, limit: limit_value, offset: offset_value }) end alias_method :collect, :collection end end end end ActiveRecord::Base.send :extend, ActiveRecord::Collections::Collectable::Model ActiveRecord::Relation.send :include, ActiveRecord::Collections::Collectable::Relation
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activerecord-collections-0.0.8 | lib/active_record/collections/collectable.rb |
activerecord-collections-0.0.7 | lib/active_record/collections/collectable.rb |