can_has_state 0.4.1 → 0.5.0

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: f184667378a0c0620b44d5d14cd31a4c44e1fde7
4
- data.tar.gz: db3b46381463581e04f3c78920258a7d9a1210eb
3
+ metadata.gz: e804c70108bf79ff92ddf4bf482f935d250c22eb
4
+ data.tar.gz: 6a05c6e5bd695850d7f5afd410ebb4aba6af643d
5
5
  SHA512:
6
- metadata.gz: 35b55898ee69682615e8d413cf928b1cda086e6bfaf51c89323fc5a71ce17c9e1362263eb0dc57519c02eb24a6eedcaaf99afeaa156f8a933b4cf14f7a272983
7
- data.tar.gz: 579f3569d6c9c5fcff3bc181c0db73c65c40a7fdd76945798c53c3e0dd2d83036d8913611a8d2ff2c664b53255db4a9d33c5f0233645d18e78d7a8a209a73f76
6
+ metadata.gz: 21508ef4e8db6892c6802722c9f0fb7e4ce8e2dee73b180fc54ade9a2de35963b6a7d536078ddf5a50d9495ed9c80cd5a5e75f7d9b421a837cca9f98121a3692
7
+ data.tar.gz: e45b6771712c7b324f39a716845bfe6de7e7a11bb0777ef6032343b9d66ce8b01ffe400abd813282c05f47ee91c72ae179c7f0c7856a0601c4a1d7f8e3fd80e6
@@ -28,7 +28,7 @@ module CanHasState
28
28
 
29
29
  # TODO: turn even guards into types of triggers ... then support :guard as a trigger param
30
30
  guards = []
31
- message = "has invalid transition from %{from} to %{to}"
31
+ message = :invalid_transition
32
32
  # TODO: differentiate messages for :from errors vs. :guard errors
33
33
 
34
34
  options.each do |key, val|
@@ -0,0 +1,5 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ invalid_state: "is not in a known state"
5
+ invalid_transition: "has an invalid transition from %{from} to %{to}"
@@ -87,17 +87,17 @@ module CanHasState
87
87
  from, to = send("#{column}_was"), send(column)
88
88
  next if from == to
89
89
  if !sm.known?(to)
90
- err << [column, "is not in a known state"]
90
+ err << [column, :invalid_state]
91
91
  elsif !sm.allow?(self, to) #state_machine_allow?(column, to)
92
- err << [column, sm.message(to) % {:from=>from, :to=>to}]
92
+ err << [column, sm.message(to), {from: from, to: to}]
93
93
  end
94
94
  end
95
95
  err
96
96
  end
97
97
 
98
98
  def can_has_valid_state_machines
99
- can_has_state_errors.each do |(column, msg)|
100
- errors.add column, msg
99
+ can_has_state_errors.each do |(column, msg, opts)|
100
+ errors.add column, msg, opts||{}
101
101
  end
102
102
  end
103
103
 
@@ -1,3 +1,3 @@
1
1
  module CanHasState
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
data/lib/can_has_state.rb CHANGED
@@ -5,4 +5,7 @@ require 'active_model'
5
5
  require "can_has_state/#{f}"
6
6
  end
7
7
 
8
+ # require 'active_support/i18n'
9
+ I18n.load_path << File.dirname(__FILE__) + '/can_has_state/locale/en.yml'
10
+
8
11
  require 'can_has_state/railtie' if defined?(Rails)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: can_has_state
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -93,6 +93,7 @@ files:
93
93
  - lib/can_has_state.rb
94
94
  - lib/can_has_state/definition.rb
95
95
  - lib/can_has_state/dirty_helper.rb
96
+ - lib/can_has_state/locale/en.yml
96
97
  - lib/can_has_state/machine.rb
97
98
  - lib/can_has_state/railtie.rb
98
99
  - lib/can_has_state/version.rb
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  requirements: []
120
121
  rubyforge_project:
121
- rubygems_version: 2.6.12
122
+ rubygems_version: 2.6.13
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Super simple state machine for ActiveModel