 		
 	dispose: -> @removeAllListeners()
 
-
 	setState: (stateObj) ->
+		# validate state change
+		
 		oldState = @__state
 		@__state = stateObj
 		
 		@removeMethods oldState.methods
 		@addMethods @__state.methods
-		@buildActions @__state.actions
+		@buildTransitions @__state.transitions
 	
 	removeMethods: (methods) ->
 		return unless methods?

	@StateChart (chart) ->
		@::__statechart = {} unless @::__statechart?

		addStackedStates = (statesObj) ->
			for name,defn of statesObj
				@::__statechart[name] =
					name   : name
					actions: defn.actions
					methods: defn.methods
			
				# TODO: validate contents for state
			
				addStackedStates defn.states

		addStackedStates chart
		
	constructor: (config) ->
		return unless @__statechart?

			@["_#{method}"] = @[method] if @[method]?
			@[method] = impl
	
	buildTransitions: (transitions) ->
		for t in transitions
			destination = @pathResolver t.destination
			chgMethod = @[t.method]
			@[t.method] = =>
				result = chgMethod.apply @, arguments
				@setState = destination unless result is true
	
	pathResolver: (path) ->
		steps = path.split '/'
		isRelative = path.indexOf '..' is 0
		
		for step in steps
			
	
module.exports = Stateful