View Source Ash.CiString (ash v3.4.47)

Represents a case insensitive string

While some data layers are aware of case insensitive string types, in order for values of this type to be used in other parts of Ash Framework, it has to be embedded in a module this allows us to implement the Comparable protocol for it.

For the type implementation, see Ash.Type.CiString

Summary

Functions

Compares an Elixir String or Ash.CiString. It will return :eq if equal, :lt, if the string is ordered alphabetically before the second string, and :gt if after.

Returns a Ash.CiString from a String, or nil if the value is nil.

Creates a case insensitive string

Returns the downcased value, only downcasing if it hasn't already been done

Converts a Ash.CiString into a normal Elixir String.

Types

casing()

@type casing() :: nil | :lower | :upper

string_type()

@type string_type() :: t() | String.t()

t()

@type t() :: %Ash.CiString{case: casing(), casted?: boolean(), string: String.t()}

Functions

compare(left, right)

@spec compare(string_type(), string_type()) :: :gt | :lt | :eq

Compares an Elixir String or Ash.CiString. It will return :eq if equal, :lt, if the string is ordered alphabetically before the second string, and :gt if after.

new(value, casing \\ nil)

@spec new(string_type() | nil, casing()) :: t() | nil

Returns a Ash.CiString from a String, or nil if the value is nil.

sigil_i(value, mods)

@spec sigil_i(
  string_type() | nil,
  charlist()
) :: t()

Creates a case insensitive string

to_comparable_string(value)

@spec to_comparable_string(string_type() | nil) :: String.t() | nil

Returns the downcased value, only downcasing if it hasn't already been done

value(ci_string)

@spec value(t()) :: String.t()

Converts a Ash.CiString into a normal Elixir String.