Module: Card::Set::All::Collection::ClassMethods
- Defined in:
- tmpsets/set/mod001-01_core/all/collection.rb
Instance Method Summary collapse
- #count_by_wql(spec) ⇒ Object
- #find_each(options = {}) ⇒ Object
- #find_in_batches(options = {}) ⇒ Object
- #search(spec) ⇒ Object
Instance Method Details
#count_by_wql(spec) ⇒ Object
16 17 18 19 20 |
# File 'tmpsets/set/mod001-01_core/all/collection.rb', line 16 def count_by_wql(spec) spec = spec.clone spec.delete(:offset) search spec.merge(:return=>'count') end |
#find_each(options = {}) ⇒ Object
22 23 24 25 26 27 |
# File 'tmpsets/set/mod001-01_core/all/collection.rb', line 22 def find_each( = {}) #this is a copy from rails (3.2.16) and is needed because this is performed by a relation (ActiveRecord::Relation) find_in_batches() do |records| records.each { |record| yield record } end end |
#find_in_batches(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'tmpsets/set/mod001-01_core/all/collection.rb', line 29 def find_in_batches( = {}) if block_given? super() do |records| yield(records) Card::Cache.reset_global end else super() end end |
#search(spec) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'tmpsets/set/mod001-01_core/all/collection.rb', line 5 def search spec query = ::Card::Query.new(spec) Card.with_logging :search, :message=>spec, :details=>query.sql.strip do results = query.run if block_given? and Array===results results.each { |result| yield result } end results end end |