state-notifier 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e4f283a3636c8326922d04e4691e30ce61f7805
4
- data.tar.gz: 280b8230def23a57c33090c6c75b6f18e6f5f52d
3
+ metadata.gz: a8eb994be65967af0b211747081962ddabf012f8
4
+ data.tar.gz: 45875129591b507a155fb2fec078a90b53878cbd
5
5
  SHA512:
6
- metadata.gz: 6cb0cc877ec19e4e7d3b65fbaa8ebfc9245aa271887c5482c171cf3be1d6c7b4461477b1ad177f7a2b3a43d349222e509b55dcf66022ceb0749734a08bc16aea
7
- data.tar.gz: 922dd2356cde0cbe8e4af59eabe40aa66faefbc60863bd143ed2312f86b92facf4baf984dff78afa95a429dde9ce815f8295721897a1a98f4657e224651d29ee
6
+ metadata.gz: f64fb11572cf4a45e43e2ed61eb07d924aaa4a93128ee35e5cda4268bcbde9baff91edd353b4744432a754bde583e996ac8674fb67c80d09a9359c31c9d007b0
7
+ data.tar.gz: 22995a9f801ce69d77c3ce9e4f1c645537a09a201f0fa832eeea8c62765b960c6768e6a7393d1c808f5017ae8bc85462454c48b2ec9cf8e7f4170e7b60cab215
data/README.md CHANGED
@@ -18,6 +18,20 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ `notify_targets(method_name)` will call `<class_name>_<method_name>` on
22
+ every target that supports it (i.e. `responds_to?`). For example, calling
23
+ `notify_target(:foo)` on an `Event` object will call `event_foo` on
24
+ supporting targets.
25
+
26
+ `notify_targets` is automatically called with `:created` and `:updated` in
27
+ `after_create` and `after_update` respectively.
28
+
29
+ For classes with a state machine the following calls are made:
30
+
31
+ - `<event_name>`
32
+ - `<target_state>` - only when its different from previous state
33
+ - `<event_name>_<target_state>` - only when its different from previous state
34
+
21
35
  class Event
22
36
  belongs_to :provider, ...
23
37
  has_many :participants, ...
@@ -1,5 +1,5 @@
1
1
  module State
2
2
  module Notifier
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -20,7 +20,10 @@ module State
20
20
 
21
21
  def notify_transition(transition)
22
22
  notify_targets transition.event
23
- notify_targets transition.to unless transition.to == transition.from
23
+ unless transition.to == transition.from
24
+ notify_targets transition.to
25
+ notify_targets "#{transition.event}_#{transition.to}"
26
+ end
24
27
  end
25
28
 
26
29
  included do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Kushner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler