Class: Cash::Query::PrimaryKey
- Defined in:
- lib/cash/query/primary_key.rb
Constant Summary
Constants inherited from Abstract
Instance Method Summary collapse
-
#initialize(active_record, ids, options1, options2) ⇒ PrimaryKey
constructor
A new instance of PrimaryKey.
- #perform ⇒ Object
Methods inherited from Abstract
#calculation?, #limit, #offset, #order, perform
Constructor Details
#initialize(active_record, ids, options1, options2) ⇒ PrimaryKey
Returns a new instance of PrimaryKey.
4 5 6 7 8 9 10 11 |
# File 'lib/cash/query/primary_key.rb', line 4 def initialize(active_record, ids, , ) super(active_record, , ) @expects_array = ids.first.kind_of?(Array) @original_ids = ids @ids = ids.flatten.compact.uniq.collect do |object| object.respond_to?(:quoted_id) ? object.quoted_id : object.to_i end end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cash/query/primary_key.rb', line 13 def perform return [] if @expects_array && @ids.empty? raise ActiveRecord::RecordNotFound if @ids.empty? super(:conditions => { :id => @ids.first }) end |