attr_sanitizable 0.0.1 → 0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/attr_sanitizable.rb +6 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c041d680a304462c9136cf9e86ed0873b96e33ab
4
- data.tar.gz: e330d8066cd1fea3a5a995f3866528fd7b20d24d
3
+ metadata.gz: 72dd4782d553d990b11e5edc6d05be3e39df8749
4
+ data.tar.gz: 3478c685102e49af3ad61489bd326044d34236de
5
5
  SHA512:
6
- metadata.gz: 2b494dba7d90770586344738f95040efc937a6c780fab10cc851a83c36ab7681540b7f9aadbbe372c3344182f5b78c224d248299f5507bf8d2427cd75fa0a993
7
- data.tar.gz: d8e0495b5ea3851824383a4c2863aef54f7c4dc87063927bf92987eb554ac197099aa0840c08ca64570252aa445f69744020302c23c8460a09f73152ef448c86
6
+ metadata.gz: cc2118480fc5d9fc8eaceef3c24088014880806e60ffeac0cb7d9ec2bcf299a445926b4a6bb43e56ed0a2ab39f5f382ba983f1911206bdba28e244a28a8c5ea5
7
+ data.tar.gz: 3f2a7da40846cf56175c7573d49789cf46b5b1e443e94f88b369b8ef0adb794ae1feffc79625478767c5af11da0509f6ef228e6f6c2f19c75b99c208a932134b
@@ -13,11 +13,13 @@ module AttrSanitizable
13
13
 
14
14
  attributes.each do |field|
15
15
  define_method "#{field}=" do |value|
16
- actions.each do |action|
17
- if !value.respond_to?(action)
18
- raise ArgumentError, "Unable to perform '#{action}' on a variable of type '#{value.class.name}'"
16
+ if !value.nil?
17
+ actions.each do |action|
18
+ if !value.respond_to?(action)
19
+ raise ArgumentError, "Unable to perform '#{action}' on a variable of type '#{value.class.name}'"
20
+ end
21
+ value = value.try(action)
19
22
  end
20
- value = value.try(action)
21
23
  end
22
24
  write_attribute(field, value)
23
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_sanitizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Price