mutator 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +13 -2
- data/lib/mutator/helpers.rb +2 -2
- data/lib/mutator/version.rb +1 -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: 266ddb73a57d444d63b9f9460df79a5eb8d19089
|
4
|
+
data.tar.gz: 8597a08ee353f97a42a3d7469bf187c494ce1723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f84541de39489ad4dab75b699e895b9f552cf86b0302cc02c93865d64001f43a646d7726515432bb29656df2a6987546122c7906c79047606a1ee0f8f73fb8e
|
7
|
+
data.tar.gz: 0e640ac518c45bf09731a77201096c1d57d860fc34ca8e7c90dc85f58e93222fee50d1c9fd9e4b355bf7adc38705f0d274ab2eebd86b3f4779817a813d1d398b
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Mutator
|
2
2
|
|
3
|
-
|
3
|
+
Yes, this is another state machine gem. Why? Well, among the major state machine gems I found, they didn't quite do what I was looking for. So I wrote my own. Plus, reinventing the wheel is fun!
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -108,6 +108,17 @@ end
|
|
108
108
|
|
109
109
|
Now you can always use `machine.deliver!` to do the transition to delivered.
|
110
110
|
|
111
|
+
### Where are my scopes?
|
112
|
+
|
113
|
+
Way back at the beginning when we included `Mutator::Helpers`, that defined class methods on `Wonder` for each invoice.
|
114
|
+
|
115
|
+
``` ruby
|
116
|
+
Wonder.machine.states #=> [:signed, :sealed, :delivered, :yours]
|
117
|
+
Wonder.signed #=> Wonder.where(state: :signed)
|
118
|
+
Wonder.sealed #=> Wonder.where(state: :sealed)
|
119
|
+
[...]
|
120
|
+
```
|
121
|
+
|
111
122
|
### That's all folks!
|
112
123
|
|
113
124
|
That's more or less it. You may or may not like the way I've done this state machine, but it works for the purposes I need it for. I'm happy to discuss changes or reasoning behind certain things. There isn't a ton of code so feel free to poke around!
|
data/lib/mutator/helpers.rb
CHANGED
@@ -5,7 +5,7 @@ module Mutator
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.included(base)
|
8
|
-
"
|
8
|
+
"Mutator::#{base.name}".constantize.states.each do |state|
|
9
9
|
base.send(:define_singleton_method, state) do
|
10
10
|
self.where(state: state)
|
11
11
|
end
|
@@ -15,7 +15,7 @@ module Mutator
|
|
15
15
|
protected
|
16
16
|
|
17
17
|
def machine_class
|
18
|
-
"
|
18
|
+
"Mutator::#{self.class.name}".constantize
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/mutator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|