active_validator 1.0.3 → 1.0.4
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 +8 -8
- data/active_validator.gemspec +2 -2
- data/lib/active_validator.rb +7 -7
- data/lib/active_validator/base.rb +16 -3
- data/lib/active_validator/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWMyOTQzZjcwNmViYzJjMTZmOTA1ZWNiNGE0YTVjNDEyNDQyYWQxYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGIwZGVlZjQ5ZmU4NmIzYjMyZGE5YzRhMjE3YTBiMGRkNWJkNDdlNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2UwM2Y0OWJlMTc5Njc2Yjg4NTg4ZDJjZTA1MDI2NGYyNmNkOWMxZjJkM2Jm
|
10
|
+
MDAzMTg1YzQzZjBjYzg3NzBjY2UwODhkNmE2Y2IwODNjYzg0YmE2NjU2NjY2
|
11
|
+
MTcwZmVkNjBlMDM3MTk5ZDMzY2EwZDYwOWJhOGQ0MDFlNjZkYjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWU3YTg2MjQzMWZjOTc4NDc4NDdlODY0YjM3NTQ0MWU5M2RkNzFhYmI3MzA4
|
14
|
+
Y2RmYThhMDhiNzE1NDA3NjAyNjRlYjIyZDdkMGJlY2FmNDE0MmIyMzhjODcx
|
15
|
+
NDQ2OTczZTE5NGIxYTRjYWI5ZjJlNmEzNTM0YjJhMDEwY2U5NjU=
|
data/active_validator.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.
|
23
|
+
spec.add_runtime_dependency "activerecord"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
|
-
spec.
|
25
|
+
spec.add_runtime_dependency "strong_parameters"
|
26
26
|
end
|
data/lib/active_validator.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
require 'active_record'
|
2
|
+
if ActiveRecord::VERSION::MAJOR >= 4
|
3
|
+
elsif ActiveRecord::VERSION::MAJOR >= 3
|
4
|
+
require 'strong_parameters'
|
5
|
+
else
|
6
|
+
raise 'Unsupported ActiveRecord version'
|
7
7
|
end
|
8
|
-
require
|
8
|
+
require 'active_validator/version'
|
9
9
|
require 'active_validator/base'
|
@@ -1,6 +1,12 @@
|
|
1
1
|
module ActiveValidator
|
2
2
|
class Base
|
3
3
|
|
4
|
+
if ActiveRecord::VERSION::MAJOR >= 4
|
5
|
+
include ActiveModel::Validations
|
6
|
+
elsif ActiveRecord::VERSION::MAJOR >= 3
|
7
|
+
include ActiveRecord::Validations
|
8
|
+
end
|
9
|
+
|
4
10
|
attr_accessor :safe_params
|
5
11
|
|
6
12
|
def initialize(params)
|
@@ -9,17 +15,17 @@ module ActiveValidator
|
|
9
15
|
end
|
10
16
|
|
11
17
|
###################
|
12
|
-
#= Class
|
18
|
+
#= Class methods =#
|
13
19
|
###################
|
14
20
|
def self.safe_params(*args)
|
15
21
|
@@safe_params = args
|
16
22
|
end
|
17
23
|
|
18
24
|
######################
|
19
|
-
#= Instance
|
25
|
+
#= Instance methods =#
|
20
26
|
######################
|
21
27
|
def delete_unsafe_params(params)
|
22
|
-
params.permit
|
28
|
+
params.permit(*@@safe_params)
|
23
29
|
end
|
24
30
|
|
25
31
|
def setup_attributes(params)
|
@@ -32,5 +38,12 @@ module ActiveValidator
|
|
32
38
|
def error_messages
|
33
39
|
{ error: errors.full_messages.uniq } unless self.valid?
|
34
40
|
end
|
41
|
+
|
42
|
+
#####################################
|
43
|
+
#= Methods to handle compatibility =#
|
44
|
+
#####################################
|
45
|
+
def new_record?
|
46
|
+
false
|
47
|
+
end
|
35
48
|
end
|
36
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|