Module: Hanami::Model::Sql::Types::Schema
- Defined in:
- lib/hanami/model/sql/types.rb,
lib/hanami/model/sql/types/schema/coercions.rb
Overview
Types for schema definitions
Defined Under Namespace
Modules: Coercions Classes: AssociationType
Constant Summary collapse
- String =
Types::Optional::Coercible::String
- Int =
Types::Strict::Nil | Types::Int.constructor(Coercions.method(:int))
- Float =
Types::Strict::Nil | Types::Float.constructor(Coercions.method(:float))
- Decimal =
Types::Strict::Nil | Types::Float.constructor(Coercions.method(:decimal))
- Bool =
Types::Strict::Nil | Types::Strict::Bool
- Date =
Types::Strict::Nil | Types::Date.constructor(Coercions.method(:date))
- DateTime =
Types::Strict::Nil | Types::DateTime.constructor(Coercions.method(:datetime))
- Time =
Types::Strict::Nil | Types::Time.constructor(Coercions.method(:time))
- Array =
Types::Strict::Nil | Types::Array.constructor(Coercions.method(:array))
- Hash =
Types::Strict::Nil | Types::Hash.constructor(Coercions.method(:hash))
- PG_JSON =
Types::Strict::Nil | Types::Any.constructor(Coercions.method(:pg_json))
- MAPPING =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ Types::String.pristine => Schema::String, Types::Int.pristine => Schema::Int, Types::Float.pristine => Schema::Float, Types::Decimal.pristine => Schema::Decimal, Types::Bool.pristine => Schema::Bool, Types::Date.pristine => Schema::Date, Types::DateTime.pristine => Schema::DateTime, Types::Time.pristine => Schema::Time, Types::Array.pristine => Schema::Array, Types::Hash.pristine => Schema::Hash, Types::String.optional.pristine => Schema::String, Types::Int.optional.pristine => Schema::Int, Types::Float.optional.pristine => Schema::Float, Types::Decimal.optional.pristine => Schema::Decimal, Types::Bool.optional.pristine => Schema::Bool, Types::Date.optional.pristine => Schema::Date, Types::DateTime.optional.pristine => Schema::DateTime, Types::Time.optional.pristine => Schema::Time, Types::Array.optional.pristine => Schema::Array, Types::Hash.optional.pristine => Schema::Hash }.freeze
Class Method Summary collapse
-
.coercible(attribute) ⇒ Object
private
Convert given type into coercible.
- .pg_json_pristines ⇒ Object private
Class Method Details
.coercible(attribute) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert given type into coercible
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/hanami/model/sql/types.rb', line 67 def self.coercible(attribute) return attribute if attribute.constrained? type = attribute.type unwrapped = type.optional? ? type.right : type # NOTE: In the future rom-sql should be able to always return Ruby # types instead of Sequel types. When that will happen we can get # rid of this logic in the block and fall back to: # # MAPPING.fetch(unwrapped.pristine, attribute) MAPPING.fetch(unwrapped.pristine) do if pg_json?(unwrapped.pristine) Schema::PG_JSON else attribute end end end |
.pg_json_pristines ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 92 93 |
# File 'lib/hanami/model/sql/types.rb', line 89 def self.pg_json_pristines @pg_json_pristines ||= ::Hash.new do |hash, type| hash[type] = (ROM::SQL::Types::PG.const_get(type).pristine if defined?(ROM::SQL::Types::PG)) end end |