lib/state_fu/lathe.rb in davidlee-state-fu-0.0.2 vs lib/state_fu/lathe.rb in davidlee-state-fu-0.2.0
- old
+ new
@@ -7,10 +7,14 @@
def initialize( machine, sprocket = nil, options={}, &block )
@machine = machine
@sprocket = sprocket
@options = options.symbolize_keys!
+
+ # extend ourself with any previously defined tools
+ machine.tools.inject_into( self )
+
if sprocket
sprocket.apply!( options )
end
if block_given?
if block.arity == 1
@@ -36,10 +40,14 @@
# is this the toplevel lathe for a machine?
def master?
!child?
end
+ def master_lathe
+ machine.lathe
+ end
+
# instantiate a child lathe and apply the given block
def apply_to( sprocket, options, &block )
StateFu::Lathe.new( machine, sprocket, options, &block )
sprocket
end
@@ -112,9 +120,16 @@
public
# helpers are mixed into all binding / transition contexts
def helper( *modules )
machine.helper *modules
+ end
+
+ # helpers are mixed into all binding / transition contexts
+ def tool( *modules )
+ machine.tool *modules
+ # inject them into self for immediate use
+ modules.flatten.extend( ToolArray ).inject_into( self )
end
#
# event definition
#