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.65 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.64 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.63 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.62 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.61 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.60 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.59 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.58 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.57 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.56 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.55 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.54 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.53 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.52 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.51 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.50 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.49 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.48 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.47 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.46 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb