solidstate 0.3.0 → 0.3.1
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 +8 -1
- data/lib/solidstate.rb +1 -1
- data/solidstate.gemspec +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5e329bd4e30446a3a96146851efb85c274c88c6
|
4
|
+
data.tar.gz: cc34e7f4b3431d15d5bfd9f3068f72276e8f71a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8de3251b5fcec27241e83e452e4ba985b0e332b906f5e72533ecb8a55d31565c4b5c7dfe0744661b04d0240c4858937d93bb9b177920307e434d27d2ebfa5c76
|
7
|
+
data.tar.gz: 8b8188819b832c9738ce478cabd6ecc7f49008bf897711d8330b5ae9319af69523ee775cfa7888359a06c91b9d4f8f1333e2987767da226d457641689b85e60c
|
data/README.md
CHANGED
@@ -26,11 +26,18 @@ In your Gemfile:
|
|
26
26
|
# whether the current status is X or Y.
|
27
27
|
|
28
28
|
p = Post.new
|
29
|
-
p.state # =>
|
29
|
+
p.state # => nil
|
30
|
+
p.state = 'draft'
|
30
31
|
p.draft? # true
|
31
32
|
p.published? # => false
|
32
33
|
p.state = 'published'
|
33
34
|
p.published? # => true
|
35
|
+
|
36
|
+
# you also have access to the list of possible states at Class.states,
|
37
|
+
# in case you need to enumerate them.
|
38
|
+
# for instance, to populate a select field's options, you'd do something like:
|
39
|
+
|
40
|
+
options = Post.states.map { |st| "<option value='#{st}'>#{st}</option>" }.join("\n")
|
34
41
|
|
35
42
|
# now, if the model class responds to validates_inclusion_of, it will
|
36
43
|
# mark the record invalid if an unknown state is set.
|
data/lib/solidstate.rb
CHANGED
@@ -57,7 +57,7 @@ module SolidState
|
|
57
57
|
|
58
58
|
define_method("#{dest}!") do
|
59
59
|
unless set_state(dest.to_sym)
|
60
|
-
raise
|
60
|
+
raise InvalidTransitionError.new("Cannot transition from #{state} to #{dest}")
|
61
61
|
end
|
62
62
|
|
63
63
|
if !respond_to?(:valid?) or (valid? && save)
|
data/solidstate.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidstate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomás Pollak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,9 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: 1.3.6
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.6.13
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Minuscule state machine.
|
126
126
|
test_files: []
|
127
|
-
has_rdoc:
|