state-notifier 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/lib/state/notifier/version.rb +1 -1
- data/lib/state/notifier.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8eb994be65967af0b211747081962ddabf012f8
|
4
|
+
data.tar.gz: 45875129591b507a155fb2fec078a90b53878cbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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, ...
|
data/lib/state/notifier.rb
CHANGED
@@ -20,7 +20,10 @@ module State
|
|
20
20
|
|
21
21
|
def notify_transition(transition)
|
22
22
|
notify_targets transition.event
|
23
|
-
|
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.
|
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-
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|