Class: AridCache::Proxies::IdProxy
- Inherits:
-
Object
- Object
- AridCache::Proxies::IdProxy
- Defined in:
- lib/arid_cache/proxies.rb
Class Method Summary collapse
-
.for(klass, find_opts = {}) ⇒ Object
Return a Proc which takes an array.
Class Method Details
.for(klass, find_opts = {}) ⇒ Object
Return a Proc which takes an array. If the array contains ActiveRecords a list of ids is returned. If the array contains ids, the corresponding records are returned. All the records must be of class klass
7 8 9 10 11 12 13 14 15 |
# File 'lib/arid_cache/proxies.rb', line 7 def self.for(klass, find_opts={}) return Proc.new do |records| if records.empty? records else records.first.is_a?(::ActiveRecord::Base) ? records.collect(&:id) : AridCache.find_all_by_id(klass, records, find_opts) end end end |