Sha256: 8d4af825966de2146bdf3899e281dfeb3a9577a9b2cb00ea8a479c164b43e5f9
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
# coding: utf-8 class OpenStruct extend Forwardable def_delegator :inst, :create, :activate def_delegator :inst, :destroy, :deactivate def_delegator :inst, :run, :run_application # 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 def create_fox_components use_as_base = nil if use_as_base.nil? self.inst = fx.() if self.inst.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 def reusable? self.reusable end 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 def instance_final_activate self.instance_result = self.instance_block.(self.inst) unless self.instance_block.nil? self.kinder.each{ |os| os.instance_final_activate unless os.reusable? } self end # launch the application def launch ingress: false create_fox_components instance_final_activate activate Enhancement.activate_ingress_handlers self if ingress run_application end # start the reusable components def starten create_fox_components instance_final_activate activate end # stop and deallocate the resusable components def stoppen destroy_fox_components end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fxruby-enhancement-0.1.0 | lib/fxruby-enhancement/ostruct-monkey.rb |