class OpenStruct
Public Instance Methods
create_fox_components(use_as_base = nil)
click to toggle source
This assumes this OpenStruct
instance represents the base, and additionaly will take an optional object to use as the actual base to allow for composures.
For the reuseable part of the tree, those are not created right away.
Returns the os base
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 16 def create_fox_components use_as_base = nil if use_as_base.nil? self.inst = fx.() if self.inst.nil? self.as_tasks.map{ |a| a.() } unless self.as_tasks.nil? self.kinder.each{ |os| os.create_fox_components unless os.reusable? } else OpenStruct.new(klass: use_as_base.class, kinder: [self], fx: ->() {use_as_base}).create_fox_components end self end
destroy_fox_components(all: false)
click to toggle source
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 35 def destroy_fox_components all: false self.deactivate unless self.inst.nil? self.kinder.each{ |os| os.destroy_fox_components if all or not os.reusable? } self.inst = nil end
instance()
click to toggle source
We must insure that instance actually is something other than nil.
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 58 def instance raise "Instance is not set for #{self.klass}" if self.inst.nil? self.inst end
instance_final_activate()
click to toggle source
We can have as many instances as we like.
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 44 def instance_final_activate self.instance_result = self.instance_block.map{ |name, inst| inst.(self.inst) } unless self.instance_block.nil? self.kinder .each{ |os| os.instance_final_activate unless os.reusable? } self end
launch(ingress: false)
click to toggle source
launch the application
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 64 def launch ingress: false create_fox_components instance_final_activate activate Enhancement.activate_ingress_handlers self if ingress run_application end
reusable?()
click to toggle source
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 31 def reusable? self.reusable end
starten()
click to toggle source
start the reusable components
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 73 def starten create_fox_components instance_final_activate activate end
stoppen()
click to toggle source
stop and deallocate the resusable components
# File lib/fxruby-enhancement/ostruct-monkey.rb, line 80 def stoppen destroy_fox_components end