Permalink
Browse files

dropping this to git before branching for rewrite

  • Loading branch information...
1 parent 970ea32 commit e4782407b8554c91000b5736c7c3443e6d5f836e @collin committed Mar 2, 2012
View
@@ -17,7 +17,6 @@ end
run_all_tests
watch("(lib)(/.*)+.coffee") { |m|
hit = m.to_s
- console.log hit
hit.gsub!(/^lib\/alpha_simprini/, "test")
run_tests(hit)
}
@@ -6,7 +6,7 @@ AS.InheritableAttrs = new AS.Mixin
@class_inheritable_attrs = []
class_methods:
- extended: ->
+ extended: ->
@class_inheritable_attrs = _.clone(@class_inheritable_attrs)
for attr in @class_inheritable_attrs
@[attr] = AS.deep_clone(@[attr])
@@ -9,6 +9,9 @@ class ShareMixin extends AS.Mixin
super(klass)
AS.Model.Share = new ShareMixin
+ LifeCycle: class LifeCycle
+ AS.StateMachine.extends(this)
+
mixed_in: ->
@define_callbacks before: ["open"], after: ["open", "load"]
@@ -9,44 +9,13 @@ _ = require "underscore"
# @event "stop_now"
# @event ""
AS.StateMachine = new AS.Mixin
- # mixed_in: (klass) ->
- # klass.state_namespace = _.uniqueId(".sm")
-
- # class_methods:
- # event: (name, options) ->
- # @events ?= []
- # options.name = name
- # @events.push options
-
- # to_dot: () ->
- # dot = ["digraph G {"]
- #
- # for event in @events
- # for state in event.from.split " "
- # for trigger in event.via.split " "
- # dot.push " #{state} -> #{event.to} [label=\"#{trigger}\"];"
- #
- # dot.push "}"
- # dot.join("\n")
-
instance_methods:
transition_state: (options) ->
if @state is options.from
@["exit_#{@state}"]?(options) if @state # default state comes from nowhere
@state = options.to
@["enter_#{options.to}"]?(options)
-
+
default_state: (state) ->
@transition_state from:undefined, to:state
-
- # bind_state_machine_to: (object) ->
- # for event in @constructor.events
- # for trigger in event.via.split(" ")
- # namespaced_trigger = trigger + @constructor.state_namespace
- # object.bind namespaced_trigger, (event) => @process(event)
- #
- # process: (event) ->
- # state_event = _.detect @constructor.events, (_event) =>
- # _event.via.match(event.type) and _event.from.match(@state)
- #
- # @transition_state(state_event) if state_event
+
@@ -102,6 +102,17 @@ exports["Model.Share"] =
AS.module = @real_module
callback()
+ "Lifecycle State Machine":
+ "share models have a Lifecycle SM": (test) ->
+ test.ok @model.lifecycle instanceof AS.Models.Share.Lifecycle
+
+ "#open":
+
+ "#load":
+ "#embedded"
+
+
+
"is new if share is undefined": (test) ->
delete @model.share
test.ok @model.new()

0 comments on commit e478240

Please sign in to comment.