Class: AttributesSanitizer::SanitizerProc
- Inherits:
-
Object
- Object
- AttributesSanitizer::SanitizerProc
- Includes:
- Comparable
- Defined in:
- lib/attributes_sanitizer/sanitizer_proc.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #<=>(another_proc) ⇒ Object
- #call(value) ⇒ Object
-
#initialize(sanitizer) ⇒ SanitizerProc
constructor
A new instance of SanitizerProc.
Constructor Details
#initialize(sanitizer) ⇒ SanitizerProc
Returns a new instance of SanitizerProc.
8 9 10 11 12 13 14 15 16 |
# File 'lib/attributes_sanitizer/sanitizer_proc.rb', line 8 def initialize(sanitizer) raise ArgumentError, "No sanitizer given" if sanitizer.nil? if sanitizer.is_a?(Proc) setup_lambda_proc(sanitizer) else setup_defined_proc(sanitizer) end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/attributes_sanitizer/sanitizer_proc.rb', line 6 def id @id end |
Instance Method Details
#<=>(another_proc) ⇒ Object
18 19 20 |
# File 'lib/attributes_sanitizer/sanitizer_proc.rb', line 18 def <=>(another_proc) self.id <=> another_proc.id end |
#call(value) ⇒ Object
22 23 24 25 26 |
# File 'lib/attributes_sanitizer/sanitizer_proc.rb', line 22 def call(value) @proc.inject(value) do |value, proc| proc.call(value) end end |