transition_validator 1.0 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
  require 'active_model'
2
2
 
3
3
  class TransitionValidator < ActiveModel::EachValidator
4
- VERSION = "1.0"
4
+ VERSION = "1.0.1"
5
5
  end
@@ -14,14 +14,14 @@ class TransitionValidator < ActiveModel::EachValidator
14
14
  end
15
15
 
16
16
  def transition? record, attribute, from, to
17
- transitions = eval "record.#{attribute}_transitions"
17
+ transitions = record.method("#{attribute}_transitions").call
18
18
  (from == to || (transitions.key?(from) && transitions[from].include?(to))) ? true : false
19
19
  end
20
-
20
+
21
21
  def transition! record, attribute, from, to
22
- method = "record.#{from}_to_#{to}_#{attribute}_transition"
22
+ method = "#{from}_to_#{to}_#{attribute}_transition"
23
23
  if record.methods.include?(method.to_sym) && from != to
24
- eval(method)
24
+ record.method(method).call
25
25
  else
26
26
  true
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transition_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-12 00:00:00.000000000Z
12
+ date: 2012-07-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
- requirement: &80187540 !ruby/object:Gem::Requirement
16
+ requirement: &77917510 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *80187540
24
+ version_requirements: *77917510
25
25
  description: A custom validator for stateful attribute transitions.
26
26
  email:
27
27
  - nizovtsevnv@gmail.com