Sha256: 342ac1599a4cca625b470f5fbaaca602556a4c50fccc1554e96a2b8fddb9b11c

Contents?: true

Size: 822 Bytes

Versions: 5

Compression:

Stored size: 822 Bytes

Contents

class DataMiner
  class Process
    attr_reader :config
    attr_reader :method_id
    attr_reader :block_description
    attr_reader :blk

    def initialize(config, method_id_or_block_description, &blk)
      @config = config
      if block_given?
        @block_description = method_id_or_block_description
        @blk = blk
      else
        @method_id = method_id_or_block_description
      end
    end
    
    def resource
      config.resource
    end
    
    def inspect
      str = %{<#Process(#{resource})}
      if block
        str << %{ called block "#{block_description}"}
      else
        str << %{ called method :#{method_id}}
      end
      str << ">"
      str
    end
    
    def run
      if blk
        blk.call
      else
        resource.send method_id
      end
      nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
data_miner-1.1.2 lib/data_miner/process.rb
data_miner-1.1.1 lib/data_miner/process.rb
data_miner-1.1.0 lib/data_miner/process.rb
data_miner-1.0.1 lib/data_miner/process.rb
data_miner-1.0.0 lib/data_miner/process.rb