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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 737e65abda45b1dc1b7ac8620811693c22832554
4
- data.tar.gz: 93039656e96b052c7f92c6ac1c2c8c729cba01aa
3
+ metadata.gz: d5e329bd4e30446a3a96146851efb85c274c88c6
4
+ data.tar.gz: cc34e7f4b3431d15d5bfd9f3068f72276e8f71a5
5
5
  SHA512:
6
- metadata.gz: bd76cc42646c4370f3f0d931a16cc112a7a9dd9116b57be6bddce77f9eb7c7465c3a1aaccbcab1ac4a4ea7ac975938216231cdcd0b7a9954259aed5fe6ea7e1b
7
- data.tar.gz: aa6734b9c93068df1c9f3d766743aed49a4f11255ac036d67cecaf9af0a5c9e24e3da4ffa985830c746fbb651c07987a8e6c2b9e453fc4e6ea0caed3da8761d7
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 # => 'draft' (default value set in database)
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 InvalidTransition.new("Cannot transition from #{state} to #{dest}")
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "solidstate"
5
- s.version = '0.3.0'
5
+ s.version = '0.3.1'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ['Tomás Pollak']
8
8
  s.email = ['tomas@forkhq.com']
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.0
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: 2017-04-18 00:00:00.000000000 Z
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.2.0
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: