Sha256: f7002d8a1a8cc93c674635007ea5f66cc6c30a83ceecdf73b7f36a9917b82fb2

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

# shared methods for card collections (Pointers, Searches, Sets, etc.)
module ClassMethods
  def search spec, comment=nil
    results = ::Card::Query.run(spec, comment)
    if block_given? && results.is_a?(Array)
      results.each { |result| yield result }
    end
    results
  end

  def count_by_wql spec
    spec = spec.clone
    spec.delete(:offset)
    search spec.merge(return: "count")
  end

  def find_each options={}
    # this is a copy from rails (3.2.16) and is needed because this
    # is performed by a relation (ActiveRecord::Relation)
    find_in_batches(options) do |records|
      records.each { |record| yield record }
    end
  end

  def find_in_batches options={}
    if block_given?
      super(options) do |records|
        yield(records)
        Card::Cache.reset_soft
      end
    else
      super(options)
    end
  end
end

def collection?
  item_cards != [self]
end

format do
  view :count do
    card.item_names.size
  end
end

format :html do
  view :carousel do
    bs_carousel unique_id, 0 do
      nest_item_array.each do |rendered_item|
        item(rendered_item)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
card-1.100.0 mod/core/set/all/collection.rb
card-1.99.6 mod/core/set/all/collection.rb
card-1.99.5 mod/core/set/all/collection.rb
card-1.99.4 mod/core/set/all/collection.rb
card-1.99.3 mod/core/set/all/collection.rb
card-1.99.2 mod/core/set/all/collection.rb
card-1.99.1 mod/core/set/all/collection.rb
card-1.99.0 mod/core/set/all/collection.rb
card-1.98.3 mod/core/set/all/collection.rb
card-1.98.2 mod/core/set/all/collection.rb
card-1.98.1 mod/core/set/all/collection.rb
card-1.98.0 mod/core/set/all/collection.rb
card-1.97.0.1 mod/core/set/all/collection.rb
card-1.97.0 mod/core/set/all/collection.rb