activerecord_json_validator 0.1.3 → 0.2
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/.travis.yml +1 -0
- data/README.md +2 -2
- data/gemfiles/Gemfile.activerecord-4.1.0.beta1 +5 -0
- data/lib/active_record/json_validator/validator.rb +13 -7
- data/lib/active_record/json_validator/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de25bab4216c8a05a29a0383db78dff2940a0758
|
4
|
+
data.tar.gz: dd70493947020e865ca313d334c0a85b3dc43835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c01dbb7d8ee0cf98794ad9111eed29109b67f89dce709e62d4cccb9007c3c06661cdcf56384a5d1a738f10d6d98dd748147d80c4666b8d2c011891e961e1eadb
|
7
|
+
data.tar.gz: 017034733e383eddb894ef52b1728ecd0fa6ad7d31731cf48fa464dbd2abede7057e9b401fda4bc6ce06643f755cf7d4b64144250d07a82317793f7176d43c5d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -59,6 +59,6 @@ user.valid? # => true
|
|
59
59
|
|
60
60
|
## About Mirego
|
61
61
|
|
62
|
-
Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We
|
62
|
+
[Mirego](http://mirego.com) is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of [talented people](http://life.mirego.com) who imagine and build beautiful Web and mobile applications. We come together to share ideas and [change the world](http://mirego.org).
|
63
63
|
|
64
|
-
We also love
|
64
|
+
We also [love open-source software](http://open.mirego.com) and we try to give back to the community as much as we can.
|
@@ -6,12 +6,18 @@ class JsonValidator < ActiveModel::EachValidator
|
|
6
6
|
|
7
7
|
super
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
# Rails 4.1 and above expose a `class` option
|
10
|
+
if options[:class]
|
11
|
+
inject_setter_method(options[:class], @attributes)
|
12
|
+
|
13
|
+
# Rails 4.0 and below calls a `#setup` method
|
14
|
+
elsif !respond_to?(:setup)
|
15
|
+
class_eval do
|
16
|
+
define_method :setup do |model|
|
17
|
+
inject_setter_method(model, @attributes)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
23
|
# Validate the JSON value with a JSON schema path or String
|
@@ -40,7 +46,7 @@ protected
|
|
40
46
|
begin
|
41
47
|
@_#{attribute}_sane_json = true
|
42
48
|
super(args)
|
43
|
-
rescue MultiJson::LoadError
|
49
|
+
rescue MultiJson::LoadError, JSON::ParserError
|
44
50
|
@_#{attribute}_sane_json = false
|
45
51
|
super({})
|
46
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_json_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Prévost
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- activerecord_json_validator.gemspec
|
169
169
|
- gemfiles/Gemfile.activerecord-3.2.x
|
170
170
|
- gemfiles/Gemfile.activerecord-4.0
|
171
|
+
- gemfiles/Gemfile.activerecord-4.1.0.beta1
|
171
172
|
- lib/active_record/json_validator/validator.rb
|
172
173
|
- lib/active_record/json_validator/version.rb
|
173
174
|
- lib/activerecord_json_validator.rb
|