Class: Remi::Transform::IfBlank
- Inherits:
-
Remi::Transform
- Object
- Remi::Transform
- Remi::Transform::IfBlank
- Defined in:
- lib/remi/transform.rb
Overview
Public: Used to replace blank values.
replace_with - Use this if the source value is blank (default: ”).
Examples:
IfBlank.new('MISSING VALUE').to_proc.call('alpha') # => "alpha"
IfBlank.new('MISSING VALUE').to_proc.call('') # => "MISSING VALUE"
Instance Attribute Summary
Attributes inherited from Remi::Transform
#multi_arg, #source_metadata, #target_metadata
Instance Method Summary collapse
-
#initialize(replace_with = '', *args, **kargs, &block) ⇒ IfBlank
constructor
A new instance of IfBlank.
- #transform(value) ⇒ Object
Methods inherited from Remi::Transform
Constructor Details
#initialize(replace_with = '', *args, **kargs, &block) ⇒ IfBlank
Returns a new instance of IfBlank.
205 206 207 208 |
# File 'lib/remi/transform.rb', line 205 def initialize(replace_with='', *args, **kargs, &block) super @replace_with = replace_with end |
Instance Method Details
#transform(value) ⇒ Object
210 211 212 |
# File 'lib/remi/transform.rb', line 210 def transform(value) value.blank? ? @replace_with : value end |