solidstate 0.3.1 → 0.4.0
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/lib/solidstate.rb +10 -12
- data/solidstate.gemspec +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: 1c6122af4d0c25f9d7f471e01e1218bbc3412736
|
4
|
+
data.tar.gz: 3a839b2b68a1fc5b7e722f47ca140bdf3f5046df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc5fd9a1496f46095faca46dbf7fb314c309a9dc27b43d326c9b72dc12452493462f215194f3c62866f292b532385517936c02f978c1109328e260eaf19bcba1
|
7
|
+
data.tar.gz: d2c6724403fd42662823d1a99e6bf0b01b51f1c4902decdf39f0e07d60884e08a3492610e614e5c0644d1e6f0787ea5941056cde5312bbfb9e3f350630951521
|
data/lib/solidstate.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'active_support/core_ext/module'
|
3
|
+
|
1
4
|
module SolidState
|
2
5
|
extend ActiveSupport::Concern
|
3
6
|
|
@@ -5,22 +8,17 @@ module SolidState
|
|
5
8
|
|
6
9
|
STATE_ATTRIBUTE = :state.freeze
|
7
10
|
|
11
|
+
mattr_accessor :possible_states
|
12
|
+
mattr_accessor :state_transitions
|
13
|
+
|
8
14
|
module ClassMethods
|
9
15
|
|
10
16
|
def states(*list, &block)
|
11
17
|
list = list.collect(&:to_s)
|
12
18
|
raise "This is not a list of names" unless list.first.respond_to?(:downcase)
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def self.states
|
18
|
-
@@states
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.state_transitions
|
22
|
-
@@state_transitions
|
23
|
-
end
|
20
|
+
self.possible_states = list
|
21
|
+
self.state_transitions = {}
|
24
22
|
|
25
23
|
if respond_to?(:validates_inclusion_of)
|
26
24
|
validates_inclusion_of STATE_ATTRIBUTE, in: list
|
@@ -52,8 +50,8 @@ module SolidState
|
|
52
50
|
# puts "From #{from} to #{to.join(' or ')}"
|
53
51
|
to.each do |dest|
|
54
52
|
|
55
|
-
state_transitions[from.to_sym] ||= []
|
56
|
-
state_transitions[from.to_sym].push(dest.to_sym)
|
53
|
+
self.state_transitions[from.to_sym] ||= []
|
54
|
+
self.state_transitions[from.to_sym].push(dest.to_sym)
|
57
55
|
|
58
56
|
define_method("#{dest}!") do
|
59
57
|
unless set_state(dest.to_sym)
|
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.
|
4
|
+
version: 0.4.0
|
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: 2018-07-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|