hashme 0.2.2 → 0.2.3

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: 7f186c4afd56dac50ae839f9bfe6ff1a929be71e
4
- data.tar.gz: 39bcb7dd73af0bc157c51109e1d7e6dc7d8f56cb
3
+ metadata.gz: eeb34cad001a9e72ba6e9bd7a7f1ea26df382bc0
4
+ data.tar.gz: 84add3cad188a7a7ef18966416a1a5e5bbd96230
5
5
  SHA512:
6
- metadata.gz: 7066de18c1fcb6173e5bbbd5bcf29bbccd6916b95da7862636731ac0886a8ab54aa9689ab763fb318413a966fac33723b0880f3d8621b5773107c4d139c21184
7
- data.tar.gz: 9f5dee6ff7e5c3c0821bd1953f058f54b4cbd62a466d51dfb72ab235eb26cfa62788755464b3fec5b3a3644dc23116934a7e9d138b16a560e8a9b8d9cc247105
6
+ metadata.gz: 3169335c642413fc0ab103c962419e2c3c2ae6bd5202a5aae0cd8995b86fe23df891bc39ec0be59f7475321b0160697c0297a353c249c1769905f335c9ec31d4
7
+ data.tar.gz: 57d07bc8e59fad1f67315c2276d654a371c76076699140f65c8edd971f7458e298032f228704b291063a042b91bb425570c7d59b2bc5e452a5d3340d2077500f
data/README.md CHANGED
@@ -118,7 +118,11 @@ u.errors.first # [:email, "can't be blank"]
118
118
 
119
119
  ## History
120
120
 
121
- ### 0.2.2 - 2016-06-04
121
+ ### 0.2.3 - 2016-06-03
122
+
123
+ * Fixing bug with validation on CastedArrays
124
+
125
+ ### 0.2.2 - 2016-06-03
122
126
 
123
127
  * Removing support for setting attributes without a property.
124
128
  * Adding a `attributes=` method.
@@ -15,7 +15,7 @@ module Hashme
15
15
  def_delegators :@_array,
16
16
  :to_a, :==, :eql?, :size,
17
17
  :first, :last, :at, :length,
18
- :each, :reject, :empty?, :map,
18
+ :each, :reject, :empty?, :map, :collect,
19
19
  :clear, :pop, :shift, :delete, :delete_at,
20
20
  :encode_json, :as_json, :to_json,
21
21
  :inspect, :any?
@@ -3,7 +3,8 @@ module Hashme
3
3
  class CastedAttributeValidator < ActiveModel::EachValidator
4
4
 
5
5
  def validate_each(document, attribute, value)
6
- values = value.is_a?(Array) ? value : [value]
6
+ is_array = value.is_a?(Array) || value.is_a?(CastedArray)
7
+ values = is_array ? value : [value]
7
8
  return if values.collect {|attr| attr.nil? || attr.valid? }.all?
8
9
  document.errors.add(attribute)
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module Hashme
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -37,6 +37,7 @@ describe Hashme::Validations do
37
37
  include Hashme
38
38
  def self.name; "Example"; end
39
39
  property :sub, submod
40
+ property :subs, [submod]
40
41
  end
41
42
  end
42
43
 
@@ -58,6 +59,14 @@ describe Hashme::Validations do
58
59
  expect(obj.sub.errors[:email]).to_not be_empty
59
60
  end
60
61
 
62
+ it "should valid attributes with casted array" do
63
+ obj = subject.new(subs: [{}])
64
+ expect(obj).to_not be_valid
65
+ expect(obj.errors[:subs]).to_not be_empty
66
+ expect(obj.subs.first.errors).to_not be_empty
67
+ expect(obj.subs.first.errors[:email]).to_not be_empty
68
+ end
69
+
61
70
  end
62
71
 
63
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Lown