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.85 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.84 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.83 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.82 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.81 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.80 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.79 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.78 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.77 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.76 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.75 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.74 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.73 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.72 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.71 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.70 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.69 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.68 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.67 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb
ree_lib-1.0.66 lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb