Sha256: dc51b04679070379ea0da25c9a95099fe70fa0843117b64e6b2d64a7ef6c2362

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module ClassMethods
  
  def search spec
    results = ::Card::Query.new(spec).run
    if block_given? and Array===results
      results.each { |result| yield result }
    end
    results
  end

  def count_by_wql(spec)
    spec.delete(:offset)
    search spec.merge(:return=>'count')
  end
  
end

def item_names(args={})
  format._render_raw.split /[,\n]/
end

def item_cards(args={})  ## FIXME this is inconsistent with item_names
  [self]
end

def item_type
  nil
end

def extended_list context = nil
  context = (context ? context.cardname : self.cardname)
  args={ :limit=>'' }
  self.item_cards(args.merge(:context=>context)).map do |x|
    x.item_cards(args)
  end.flatten.map do |x|
    x.item_cards(args)
  end.flatten.map do |y|
    y.item_names(args)
  end.flatten
  # this could go on and on.  more elegant to recurse until you don't have a collection
end

def contextual_content context_card, format_args={}
  format_args[:not_current] = true
  context_card.format(format_args).process_content(
    self.format(:not_current=>true)._render_raw
  )
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wagn-1.13.0.pre2 mods/core/sets/all/collection.rb
wagn-1.13.0.pre1 mods/core/sets/all/collection.rb
wagn-1.13.0.pre mods/core/sets/all/collection.rb