Class: Boson::RunnerLibrary

Inherits:
Library
  • Object
show all
Defined in:
lib/boson/runner_library.rb

Overview

Library created by Runner

Constant Summary

Constant Summary

Constants inherited from Library

Library::ATTRIBUTES

Instance Attribute Summary

Attributes inherited from Library

#lib_file, #new_commands, #new_module

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Library

#clean_name, #command_object, #command_objects, handles, #initialize, #library_type

Methods included from Library::API

#before_initialize, #config, #local?, #namespace_object

Methods included from Loader

#actual_load_commands, #after_include, #before_load_commands, #clean_library_commands, #detect_additions, #handle_method_conflict_error, #load, #load_commands, #load_commands?, #loaded_correctly?, #method_conflicts, #module_callbacks, #set_library_commands

Constructor Details

This class inherits a constructor from Boson::Library

Class Method Details

.delegate_runner_methods(runner, mod) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/boson/runner_library.rb', line 8

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

Instance Method Details

#load_source_and_set_moduleObject

Since Boson expects libraries to be modules, creates a temporary module and delegates its methods to it



25
26
27
28
29
# File 'lib/boson/runner_library.rb', line 25

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

#set_name(runner) ⇒ Object



18
19
20
21
# File 'lib/boson/runner_library.rb', line 18

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