Class: ReeMapper::String

Inherits:
AbstractType show all
Defined in:
lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



14
15
16
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb', line 14

def cast(value)
  serialize(value)
end

#db_dump(value) ⇒ Object



19
20
21
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb', line 19

def db_dump(value)
  serialize(value)
end

#db_load(value) ⇒ Object



24
25
26
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb', line 24

def db_load(value)
  serialize(value)
end

#serialize(value) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb', line 5

def serialize(value)
  if value.is_a? String
    value
  else
    raise ReeMapper::TypeError.new("should be a string, got `#{truncate(value.inspect)}`")
  end
end