Sha256: 483e4fde087b4303f50f8a3d6aef385f5f46ed71a2c4b33772f90d18965631c3

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All
# Set: All cards (Collection)
#
# shared methods for card collections (Pointers, Searches, Sets, etc.)
module Collection;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/collection.rb"; end
module ClassMethods
  def search spec, comment=nil, &block
    results = ::Card::Query.run(spec, comment)
    results.each(&block) if block_given? && results.is_a?(Array)
    results
  end

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

  def find_each options={}, &block
    # 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(&block)
    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

module Format; module_parent.send :register_set_format, Card::Format, self; extend Card::Set::AbstractFormat
  view :count do
    card.item_names.size
  end
end

module HtmlFormat; module_parent.send :register_set_format, Card::Format::HtmlFormat, self; extend Card::Set::AbstractFormat
  view :carousel do
    bs_carousel unique_id, 0 do
      nest_item_array.each do |rendered_item|
        item(rendered_item)
      end
    end
  end
end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card/mod/core/set/all/collection.rb ~~

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-1.101.7 tmpsets/set/mod002-core/all/collection.rb
card-1.101.6 tmpsets/set/mod002-core/all/collection.rb