stateful_enum 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffeec178154391f427428dcb96dfe904071069a8
4
- data.tar.gz: 9928fb31c685db67d2a9d70d232b0d9736fa88ad
3
+ metadata.gz: e93fa3aad64f0c66c8d1e5a14993b0176c269274
4
+ data.tar.gz: 0712a38f75019a9ee82e8a121e8d6d509aa208f4
5
5
  SHA512:
6
- metadata.gz: 9330b01347ddc68584bd6b87417e22d0577eb6f15e4a902c40af48b5a60b408977ff799df33280eed09800421004b1c3e9bffe264d00b017f38a5545f22352cb
7
- data.tar.gz: 9bad2968b578fcf1141fb78c1b69284a6750c64596a68056ff733173aba2492f58842ff6005bffd79ee435d7140f079e44e2ee0e52b814a065ce64e187f337d3
6
+ metadata.gz: f54ad2ee66dc272f0f0c6594c847b5df6e70deb7f6e851e570f8442a1e8ae9c7301a512389c3fec15f188fe3fb26f73e971029d004f83d9b1489e8ab8899debc
7
+ data.tar.gz: c734c80ccf99dd5c077f643c9769369b1937fc7a8141fb48db674cae5d5e149b53fb618c4cd1db088aecf1bf92743a7a45f51e7d02ed805647bc41f93354a094
@@ -12,7 +12,8 @@ module StatefulEnum
12
12
 
13
13
  if block
14
14
  definitions.each_key do |column|
15
- StatefulEnum::Machine.new self, column, enum[column], &block
15
+ states = enum[column]
16
+ StatefulEnum::Machine.new self, column, (states.is_a?(Hash) ? states.keys : states), &block
16
17
  end
17
18
  end
18
19
  end
@@ -4,7 +4,7 @@ module StatefulEnum
4
4
  @model, @column, @states, @event_names = model, column, states, []
5
5
 
6
6
  # undef non-verb methods e.g. Model#active!
7
- states.each_key do |state|
7
+ states.each do |state|
8
8
  @model.send :undef_method, "#{state}!"
9
9
  end
10
10
 
@@ -65,16 +65,16 @@ module StatefulEnum
65
65
  end
66
66
  end
67
67
  transitions.each_pair do |from, to|
68
- raise "Undefined state #{to}" unless @states.has_key? to
68
+ raise "Undefined state #{to}" unless @states.include? to
69
69
  Array(from).each do |f|
70
- raise "Undefined state #{f}" unless @states.has_key? f
70
+ raise "Undefined state #{f}" unless @states.include? f
71
71
  @transitions[f] = [to, options[:if]]
72
72
  end
73
73
  end
74
74
  end
75
75
 
76
76
  def all
77
- @states.keys
77
+ @states
78
78
  end
79
79
 
80
80
  def before(&block)
@@ -1,3 +1,3 @@
1
1
  module StatefulEnum
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stateful_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-15 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler