Sha256: 205be7be3a62a9e303fdb7fb98e0f4d2a8a3306a44698536efd3bded3decb52f

Contents?: true

Size: 940 Bytes

Versions: 10

Compression:

Stored size: 940 Bytes

Contents

module Boson
  # Library created by Runner
  class RunnerLibrary < Library
    handles {|source|
      source.is_a?(Module) && defined?(Runner) && source.ancestors.include?(Runner)
    }

    def self.delegate_runner_methods(runner, mod)
      mod.module_eval do
        runner.public_instance_methods(false).each do |meth|
          define_method(meth) do |*args, &block|
            runner.new.send(meth, *args, &block)
          end
        end
      end
    end

    def set_name(runner)
      @runner = runner #reference needed elsewhere
      @runner.to_s[/[^:]+$/].downcase
    end

    # Since Boson expects libraries to be modules, creates a temporary module
    # and delegates its methods to it
    def load_source_and_set_module
      @module = Util.create_module Boson::Commands, @name
      MethodInspector.instance.rename_store_key @runner, @module
      self.class.delegate_runner_methods @runner, @module
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
boson-1.3.0 lib/boson/runner_library.rb
boson-1.2.4 lib/boson/runner_library.rb
boson-1.2.3 lib/boson/runner_library.rb
boson-1.2.2 lib/boson/runner_library.rb
boson-1.2.1 lib/boson/runner_library.rb
boson-1.2.0 lib/boson/runner_library.rb
boson-1.1.1 lib/boson/runner_library.rb
boson-1.1.0 lib/boson/runner_library.rb
boson-1.0.1 lib/boson/runner_library.rb
boson-1.0.0 lib/boson/runner_library.rb