Sha256: a5d2c6550764d77e01c8e283f741984907360f81fcac492b564f2d75dc28c40d

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 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_description
        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

2 entries across 2 versions & 1 rubygems

Version Path
data_miner-1.1.4 lib/data_miner/process.rb
data_miner-1.1.3 lib/data_miner/process.rb