Sha256: 31bbeb837a3059b0ce9dd623f9f837af673f232dbd904b1414d19c37f7ccd3cd

Contents?: true

Size: 527 Bytes

Versions: 7

Compression:

Stored size: 527 Bytes

Contents

# frozen_string_literal: true

# this class is used to allow batch treatment
class Batch
  def each(&proc)
    @data.each do |val|
      atome_found = grab(val)
      instance_exec(atome_found, &proc) if proc.is_a?(Proc)
    end
  end

  def initialize(params)
    @data = params
    # self
  end

  def dispatch(method, args, &block)
    @data.each do |atome_found|
      args.each do |arg|
        grab(atome_found).send(method, arg, &block)
      end
    end
    # we return self to allow method chaining
    self
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
atome-0.5.4.1.9 lib/atome/kernel/batch.rb
atome-0.5.4.1.7 lib/atome/kernel/batch.rb
atome-0.5.4.1.3 lib/atome/kernel/batch.rb
atome-0.5.4.1.2 lib/atome/kernel/batch.rb
atome-0.5.4.1.1 lib/atome/kernel/batch.rb
atome-0.5.4.1.0 lib/atome/kernel/batch.rb
atome-0.5.4.0.9 lib/atome/kernel/batch.rb