api-model 1.0.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/api-model.gemspec +1 -1
- data/lib/api_model/instance_methods.rb +2 -0
- data/spec/api-model/api_model_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73d9deb33b32e4fa619eea2bb1c268e4f3ab885b
|
4
|
+
data.tar.gz: 33b7cadeba5a48095b8f3c5817bf240dfcff121d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ab1de85de04b518dc8deaf7966f70735fab6962dde39a79d6d6dd673a62d35ac926bc16205f1c6e878a676ab97aeec8f8e92cdd0dd581d833a51180468b21b
|
7
|
+
data.tar.gz: e9abbedbedacc988511f559fdcbd8a81ff6d690b03854ebcbf09bacec69bae70bc164bad463b28a12cc7487a9b4d2869f2a6183e2ee0816f4b24bfd86e57d830
|
data/Gemfile.lock
CHANGED
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.
|
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.
|
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-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|