Sha256: bef17b88f846280056a2ee198693de697cff93816c2bb746818e713a497efbbc

Contents?: true

Size: 982 Bytes

Versions: 68

Compression:

Stored size: 982 Bytes

Contents

# frozen_string_literal: true

class ReeMapper::String < ReeMapper::AbstractType
  contract(Any, Kwargs[name: String, role: Nilor[Symbol, ArrayOf[Symbol]]] => String).throws(ReeMapper::TypeError)
  def serialize(value, name:, role: nil)
    if value.is_a? String
      value
    else
      raise ReeMapper::TypeError, "`#{name}` should be a string"
    end
  end

  contract(Any, Kwargs[name: String, role: Nilor[Symbol, ArrayOf[Symbol]]] => String).throws(ReeMapper::TypeError)
  def cast(value, name:, role: nil)
    serialize(value, name: name, role: role)
  end

  contract(Any, Kwargs[name: String, role: Nilor[Symbol, ArrayOf[Symbol]]] => String).throws(ReeMapper::TypeError)
  def db_dump(value, name:, role: nil)
    serialize(value, name: name, role: role)
  end

  contract(Any, Kwargs[name: String, role: Nilor[Symbol, ArrayOf[Symbol]]] => String).throws(ReeMapper::TypeError)
  def db_load(value, name:, role: nil)
    serialize(value, name: name, role: role)
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
ree_lib-1.0.45 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.44 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.43 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.42 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.41 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.40 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.39 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.38 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.37 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.36 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.35 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.34 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.33 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.32 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.31 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.30 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb