Module: ComponentTester
- Defined in:
- lib/adhearsion/component_manager/component_tester.rb
Class Method Summary collapse
-
.new(component_name, component_directory) ⇒ Module
An anonymous module which includes the ComponentTester module.
Instance Method Summary collapse
Class Method Details
.new(component_name, component_directory) ⇒ Module
Returns an anonymous module which includes the ComponentTester module.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/adhearsion/component_manager/component_tester.rb', line 10 def new(component_name, component_directory) component_directory = File. component_directory main_file = component_directory + "/#{component_name}/#{component_name}.rb" component_manager = Adhearsion::Components::ComponentManager.new(component_directory) component_module = Adhearsion::Components::ComponentManager::ComponentDefinitionContainer.load_file main_file Module.new do extend ComponentTester (class << self; self; end).send(:define_method, :component_manager) { component_manager } (class << self; self; end).send(:define_method, :component_name) { component_name } (class << self; self; end).send(:define_method, :component_module) { component_module } (class << self; self; end).send(:define_method, :component_directory) { component_directory } define_method(:component_manager) { component_manager } define_method(:component_name) { component_name } define_method(:component_module) { component_module } define_method(:component_directory) { component_directory } def self.const_missing(name) component_module.const_get name end end end |
Instance Method Details
#config ⇒ Object
44 45 46 |
# File 'lib/adhearsion/component_manager/component_tester.rb', line 44 def config component_manager.configuration_for_component_named component_name end |
#helper_method(name) ⇒ Object
40 41 42 |
# File 'lib/adhearsion/component_manager/component_tester.rb', line 40 def helper_method(name) Object.new.extend(component_module).method(name) end |
#initialize! ⇒ Object
48 49 50 51 52 53 |
# File 'lib/adhearsion/component_manager/component_tester.rb', line 48 def initialize! = component_module..send(:instance_variable_get, :@metadata) if && [:initialization_block].kind_of?(Proc) [:initialization_block].call end end |