hero 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Its a bird, its a plane, its... its... my Hero
4
4
 
5
+ ![Hero GEM](http://hopsoft.github.com/hero/images/hero.jpg)
6
+
5
7
  Ever wish that you could unwind the spaghetti and get out of the corner you've been backed into?
6
8
 
7
9
  ### Hero is here to save the day
@@ -19,7 +21,7 @@ One that evolved from the real world with concrete use cases and actual producti
19
21
 
20
22
  The problem has always been: How to effectively model a business process within your app.
21
23
 
22
- Things start simply enough but eventually edge cases force *gothcas* into
24
+ Things start simply enough but eventually edge cases force *gotchas* into
23
25
  various libs, modules, and classes. Before you know you it,
24
26
  you have a lump of spaghetti that's difficult to maintain and even harder to improve.
25
27
 
@@ -85,7 +87,7 @@ end
85
87
 
86
88
  Hero approaches this problem differently.
87
89
  It asks us to <a href="http://en.wikipedia.org/wiki/Decomposition_(computer_science)">decompose</a>
88
- the login requirement into business processes which might look something like this.
90
+ the login requirement into a business processes looks something like this.
89
91
 
90
92
  #### Login
91
93
 
@@ -172,3 +174,4 @@ I know what you're thinking, and you're right.
172
174
  This doesn't pass DHH's before/after test,
173
175
  but lets start throwing edge cases at it and see what happens.
174
176
 
177
+ More soon. Stay tuned...
data/lib/hero/formula.rb CHANGED
@@ -13,6 +13,7 @@ module Hero
13
13
  def_delegator :formulas, :length, :count
14
14
 
15
15
  def reset
16
+ formulas.values.each { |f| f.delete_observers }
16
17
  @formulas = {}
17
18
  end
18
19
 
@@ -40,9 +41,9 @@ module Hero
40
41
  @observer.steps << step
41
42
  end
42
43
 
43
- def notify(target=nil, options={})
44
+ def notify(context=nil, options={})
44
45
  changed
45
- notify_observers(target, options)
46
+ notify_observers(context, options)
46
47
  end
47
48
 
48
49
  alias :run :notify
data/lib/hero/observer.rb CHANGED
@@ -5,8 +5,8 @@ module Hero
5
5
  @steps ||= []
6
6
  end
7
7
 
8
- def update(target, options={})
9
- steps.each { |step| step.call(target, options) }
8
+ def update(context, options={})
9
+ steps.each { |step| step.call(context, options) }
10
10
  end
11
11
 
12
12
  end
data/spec/hero_spec.rb CHANGED
@@ -35,6 +35,16 @@ describe Hero::Formula do
35
35
  assert_equal Hero::Formula.count, 10
36
36
  end
37
37
 
38
+ it "should unregister formula observers on reset" do
39
+ formula = Hero::Formula[:test_formula]
40
+ assert_equal Hero::Formula.count, 1
41
+ formula.add_step {}
42
+ assert_equal formula.count_observers, 1
43
+ Hero::Formula.reset
44
+ assert_equal Hero::Formula.count, 0
45
+ assert_equal formula.count_observers, 0
46
+ end
47
+
38
48
  describe "a registered formula" do
39
49
  it "should support adding steps" do
40
50
  Hero::Formula.register(:test_formula)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: