Sha256: fab1341199779ea8a80d45fced8ef584d152d3709a425c1c522f4387aa3008c1

Contents?: true

Size: 855 Bytes

Versions: 4

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

class Batch

  def each(&proc)
    value.each do |val|
      instance_exec(val, &proc) if proc.is_a?(Proc)
    end
  end

  def id(val = nil)
    if val
      @id = val
    else
      @id
    end
  end

  def initialize(params)
    @id = params[:id] || "batch_#{Universe.atomes.length}"
    Universe.add_to_atomes(@id, self)
  end

  def dispatch (method, *args, &block)
    @data.each do |atome_found|
      atome_found.send(method, *args, &block)
    end
  end

  # TODO:  automatise collector methods creation when creato,g a new atome type
  def color(args, &block)

    dispatch(:color, args, &block)
  end

  def shadow(args, &block)
    dispatch(:color, args, &block)
  end

  def method_missing(method, *args, &block)
    dispatch(method, args, &block)
  end

  def data(collection)
    @data = collection
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atome-0.5.3.7.3 lib/atome/kernel/batch.rb
atome-0.5.3.7.2 lib/atome/kernel/batch.rb
atome-0.5.3.4 lib/atome/kernel/batch.rb
atome-0.5.3.2 lib/atome/kernel/batch.rb