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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4291b8adabe3846dfd4edd7f67f5369d16a5396
4
- data.tar.gz: 1d35c9d9c7cf28b55f886771492016b937bbd781
3
+ metadata.gz: de25bab4216c8a05a29a0383db78dff2940a0758
4
+ data.tar.gz: dd70493947020e865ca313d334c0a85b3dc43835
5
5
  SHA512:
6
- metadata.gz: f4c5d178cde22ce57645c37052ada36c9ed818f59a8969011840720ebd024fc11d259be0e31e34c15140b5c6831b8c7be0f044f2c3ea063a121627680031891e
7
- data.tar.gz: 7c30d3aeeec9dd3b2dcb4ed1ba311486fc39f279300d5c33a13226647892e7cdf0ca8893f74f3a9b93fbbdd799b16145587f076bf644686dcf66af85a5709c42
6
+ metadata.gz: c01dbb7d8ee0cf98794ad9111eed29109b67f89dce709e62d4cccb9007c3c06661cdcf56384a5d1a738f10d6d98dd748147d80c4666b8d2c011891e961e1eadb
7
+ data.tar.gz: 017034733e383eddb894ef52b1728ecd0fa6ad7d31731cf48fa464dbd2abede7057e9b401fda4bc6ce06643f755cf7d4b64144250d07a82317793f7176d43c5d
data/.travis.yml CHANGED
@@ -5,6 +5,7 @@ rvm:
5
5
  - 1.9.3
6
6
 
7
7
  gemfile:
8
+ - gemfiles/Gemfile.activerecord-4.1.0.beta1
8
9
  - gemfiles/Gemfile.activerecord-4.0
9
10
  - gemfiles/Gemfile.activerecord-3.2.x
10
11
 
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 proudly build mobile applications for [iPhone](http://mirego.com/en/iphone-app-development/ "iPhone application development"), [iPad](http://mirego.com/en/ipad-app-development/ "iPad application development"), [Android](http://mirego.com/en/android-app-development/ "Android application development"), [Blackberry](http://mirego.com/en/blackberry-app-development/ "Blackberry application development"), [Windows Phone](http://mirego.com/en/windows-phone-app-development/ "Windows Phone application development") and [Windows 8](http://mirego.com/en/windows-8-app-development/ "Windows 8 application development") in beautiful Quebec City.
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 [open-source software](http://open.mirego.com/) and we try to extract as much code as possible from our projects to give back to the community.
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.
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
4
+
5
+ gem 'activerecord', '~> 4.1.0.beta1'
@@ -6,12 +6,18 @@ class JsonValidator < ActiveModel::EachValidator
6
6
 
7
7
  super
8
8
 
9
- inject_setter_method(options[:class], @attributes) if options[:class]
10
- end
11
-
12
- # Only respond to `#setup` if we’re in Rails 4.0 or less
13
- def setup(model)
14
- inject_setter_method(model, @attributes)
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
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module JSONValidator
3
- VERSION = '0.1.3'
3
+ VERSION = '0.2'
4
4
  end
5
5
  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.1.3
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: 2013-12-30 00:00:00.000000000 Z
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