Class: PGTrunk::Serializers::LowercaseStringSerializer

Inherits:
ActiveRecord::Type::Value
  • Object
show all
Defined in:
lib/pg_trunk/core/serializers/lowercase_string_serializer.rb

Overview

Cast the attribute value as a non-empty stripped string in lowercase

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



8
9
10
# File 'lib/pg_trunk/core/serializers/lowercase_string_serializer.rb', line 8

def cast(value)
  value.to_s.presence&.downcase&.strip
end

#serialize(value) ⇒ Object



12
13
14
# File 'lib/pg_trunk/core/serializers/lowercase_string_serializer.rb', line 12

def serialize(value)
  value.to_s
end