Class: Betterdocs::Sanitizer
- Inherits:
-
Object
- Object
- Betterdocs::Sanitizer
- Defined in:
- lib/betterdocs/sanitizer.rb
Constant Summary collapse
- JSON_NONSTRING_TYPES =
Tins::ModuleGroup[ TrueClass, FalseClass, NilClass, Numeric, Array, Hash, ]
Instance Method Summary collapse
-
#initialize(&sanitize) ⇒ Sanitizer
constructor
A new instance of Sanitizer.
- #sanitize(value) ⇒ Object
Constructor Details
#initialize(&sanitize) ⇒ Sanitizer
Returns a new instance of Sanitizer.
11 12 13 |
# File 'lib/betterdocs/sanitizer.rb', line 11 def initialize(&sanitize) @sanitize = sanitize end |
Instance Method Details
#sanitize(value) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/betterdocs/sanitizer.rb', line 15 def sanitize(value) @sanitize or return value if JSON_NONSTRING_TYPES === value value else @sanitize.(value.to_s) end end |