Sha256: 2706cc42c461db9fe824aa78e6f9b5297bfbb15e434c5aae6adff7262d9a056c

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 Bytes

Contents

# encoding: utf-8

module Forkforge
  class Handler
    def initialize handler_class, *args
      @handler = handler_class.split('::').inject(Object) do |mod, clazz|
        mod.const_get(clazz)
      end.new *args

      @delayed = []
    end

    def method_missing method, *args, &block
      if @handler.respond_to? method
        @handler.send(method, *args, &block)
        @delayed.clear
      else
        @delayed.unshift "#{method}"
      end
    end

    def parse input
      self.instance_eval %Q{
        #{File.read input}
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forkforge-0.0.4 lib/forkforge/dsl/handler.rb
forkforge-0.0.3 lib/forkforge/dsl/handler.rb