scrubby 0.3.0 → 0.3.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.
- data/VERSION +1 -1
- data/lib/scrubby.rb +5 -1
- data/scrubby.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/scrubby.rb
CHANGED
@@ -64,6 +64,10 @@ module Scrubby
|
|
64
64
|
scrubber = block_given? ? block : instance_method(:scrub)
|
65
65
|
self.scrubbers = attributes.inject({}){|s,a| s.merge!(a.to_s => scrubber) }
|
66
66
|
end
|
67
|
+
|
68
|
+
def scrubby?
|
69
|
+
!scrubbers.blank?
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
module InstanceMethods
|
@@ -71,7 +75,7 @@ module Scrubby
|
|
71
75
|
# scrubber exists for the given attribute and if so, scrub the given value before passing it
|
72
76
|
# on to the original +write_attribute+ method.
|
73
77
|
def write_attribute_with_scrub(attribute, value)
|
74
|
-
if scrubber = scrubbers[attribute.to_s]
|
78
|
+
if self.class.scrubby? && scrubber = scrubbers[attribute.to_s]
|
75
79
|
value = scrubber.bind(self).call(value)
|
76
80
|
end
|
77
81
|
|
data/scrubby.gemspec
CHANGED