api-model 1.0.0 → 1.0.1

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: 11061671355750be204f15d713db7d0c7086dffb
4
- data.tar.gz: adc621e2d2c3a14aa0fc0506f95be9b4ac56244c
3
+ metadata.gz: 73d9deb33b32e4fa619eea2bb1c268e4f3ab885b
4
+ data.tar.gz: 33b7cadeba5a48095b8f3c5817bf240dfcff121d
5
5
  SHA512:
6
- metadata.gz: 6fe21b33dcb485f05b08c1da02c264a27e0e757e408aa72b39cbf178003a84b46d61d05585b6157e088c8fd614602bcf603f1fbe21d142aa340fde379101082b
7
- data.tar.gz: 0a0e470c1ed7274175ea78e1cd00d3e5f529bedb9350e083a4df6403ddf32c6d25e095a9c062ddf96a7d74f5ce11d38ce5c27227dbb6145e2d4af0cb69ea1662
6
+ metadata.gz: 50ab1de85de04b518dc8deaf7966f70735fab6962dde39a79d6d6dd673a62d35ac926bc16205f1c6e878a676ab97aeec8f8e92cdd0dd581d833a51180468b21b
7
+ data.tar.gz: e9abbedbedacc988511f559fdcbd8a81ff6d690b03854ebcbf09bacec69bae70bc164bad463b28a12cc7487a9b4d2869f2a6183e2ee0816f4b24bfd86e57d830
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-model (1.0.0)
4
+ api-model (1.0.1)
5
5
  activemodel
6
6
  activesupport
7
7
  hashie
data/api-model.gemspec CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "api-model"
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
  s.authors = ["Damien Timewell"]
7
7
  s.email = ["mail@damientimewell.com"]
8
8
  s.homepage = "https://github.com/iZettle/api-model"
@@ -22,6 +22,8 @@ module ApiModel
22
22
  # Convenience method to handle error hashes and set them as ActiveModel errors on instances.
23
23
  # Using the `obj`, you can move the errors on to child classes if needed.
24
24
  def set_errors_from_hash(errors_hash, obj = self)
25
+ return false unless errors_hash.is_a? Hash
26
+
25
27
  errors_hash.each do |field,messages|
26
28
  if messages.is_a?(Array)
27
29
  messages.each do |message|
@@ -154,6 +154,10 @@ describe ApiModel do
154
154
  car.errors.size.should eq 0
155
155
  blog_post.errors[:name].should eq ["is bad"]
156
156
  end
157
+
158
+ it 'should return false if errors is not a hash' do
159
+ car.set_errors_from_hash("Foobar").should be_false
160
+ end
157
161
  end
158
162
 
159
163
  describe "updating attributes from a hash" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Timewell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport