class Koine::Attributes::Adapter::String

Public Instance Methods

empty_to_nil() click to toggle source
# File lib/koine/attributes/adapter/string.rb, line 7
def empty_to_nil
  with_nil_value(nil)
  @empty_to_nil = true
  self
end
trim_empty_spaces() click to toggle source
# File lib/koine/attributes/adapter/string.rb, line 13
def trim_empty_spaces
  @trim_empty_spaces = true
  self
end

Private Instance Methods

coerce_not_nil(value) click to toggle source
# File lib/koine/attributes/adapter/string.rb, line 20
def coerce_not_nil(value)
  secure do
    value = String(value)
    value = value.strip if @trim_empty_spaces
    return nil if value.empty? && @empty_to_nil

    value
  end
end