attributes_sanitizer 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/attributes_sanitizer/concern.rb +7 -8
- data/lib/attributes_sanitizer/railtie.rb +5 -0
- data/lib/attributes_sanitizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a0c3bafdd04afef4a778d991247d32bd27537fde4c0b005b2ad0ddaee8bbbe3
|
4
|
+
data.tar.gz: 9fe53322bee091b4e7a6df4e6e3fa8efe4f759c8dae69a125003450ae7ee3bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c081ce4dedf43daa64700455d7fcb1e705ac6e1701bf4c3f6a575904b0e566874f5804f04c9dad7c53293ceb1eb08caba5a863562c6f27c3538f8850fefa885
|
7
|
+
data.tar.gz: 3b7574ce20365ac239cfefc1ad33021f66c952e3a7b39e6e6d5caa71cc545dca08bc790a4be8800508fc1dd94fba5d8c63e4102e58e4843155fa36f33ee1c14e
|
data/README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module AttributesSanitizer::Concern
|
2
|
-
|
3
|
-
klass.cattr_accessor :attributes_sanitize_map
|
4
|
-
klass.extend ClassMethods
|
5
|
-
end
|
2
|
+
extend ActiveSupport::Concern
|
6
3
|
|
7
|
-
|
8
|
-
def
|
9
|
-
|
4
|
+
class_methods do
|
5
|
+
def attributes_sanitize_map
|
6
|
+
@attributes_sanitize_map ||= {}
|
7
|
+
end
|
10
8
|
|
9
|
+
def sanitize_attributes(*attributes)
|
11
10
|
fetch_sanitizers_from_options(attributes).each do |sanitizer|
|
12
11
|
sanitizer = AttributesSanitizer::SanitizerProc.new(sanitizer)
|
13
12
|
|
@@ -21,7 +20,7 @@ module AttributesSanitizer::Concern
|
|
21
20
|
alias_method :sanitize_attribute, :sanitize_attributes
|
22
21
|
|
23
22
|
def execute_sanitizers_for(attribute, value)
|
24
|
-
return value if self.attributes_sanitize_map.blank? || value.nil?
|
23
|
+
return value if self.attributes_sanitize_map[attribute].blank? || value.nil?
|
25
24
|
|
26
25
|
self.attributes_sanitize_map[attribute].reduce(value) do |value, sanitizer|
|
27
26
|
sanitizer.call(value)
|