class Format::Formatter
Attributes
mapper[R]
modifier[R]
Public Class Methods
new(yml, modifiers)
click to toggle source
# File lib/src/format/formatter.rb, line 6 def initialize(yml, modifiers) @mapper = Format::Mapper.new(yml) @modifier = Format::Modifier.new(yml, modifiers) end
Public Instance Methods
format_value(value, props)
click to toggle source
# File lib/src/format/formatter.rb, line 11 def format_value(value, props) modifier_prop, mapper_prop = props.values_at(:modifier, :mapper) value .then { |it| modifier.apply(it, modifier_prop) } .then { |it| nullify_empty_value(it) } .then { |it| mapper.apply(it, mapper_prop) } end
Private Instance Methods
nullify_empty_value(value)
click to toggle source
# File lib/src/format/formatter.rb, line 24 def nullify_empty_value(value) value.blank? || value.try(:zero?) ? nil : value end