Class: Hanami::Model::Sql::Entity::Schema Private
- Inherits:
-
Entity::Schema
- Object
- Entity::Schema
- Hanami::Model::Sql::Entity::Schema
- Defined in:
- lib/hanami/model/sql/entity/schema.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
SQL Entity schema
This schema setup is automatic.
Hanami looks at the database columns, associations and potentially to the mapping in the repository (optional, only for legacy databases).
Instance Method Summary collapse
-
#attribute?(name) ⇒ TrueClass, FalseClass
private
Check if the attribute is known.
-
#call(attributes) ⇒ Object
(also: #[])
private
Process attributes.
-
#initialize(registry, relation, mapping) ⇒ Hanami::Model::Sql::Entity::Schema
constructor
private
Build a new instance of Schema according to database columns, associations and potentially to mapping defined by the repository.
Constructor Details
#initialize(registry, relation, mapping) ⇒ Hanami::Model::Sql::Entity::Schema
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.
Build a new instance of Schema according to database columns, associations and potentially to mapping defined by the repository.
36 37 38 39 40 41 |
# File 'lib/hanami/model/sql/entity/schema.rb', line 36 def initialize(registry, relation, mapping) attributes = build(registry, relation, mapping) @schema = Types::Coercible::Hash.schema(attributes) @attributes = Hash[attributes.map { |k, _| [k, true] }] freeze end |
Instance Method Details
#attribute?(name) ⇒ TrueClass, FalseClass
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.
Check if the attribute is known
67 68 69 |
# File 'lib/hanami/model/sql/entity/schema.rb', line 67 def attribute?(name) attributes.key?(name) end |
#call(attributes) ⇒ Object Also known as: []
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.
Process attributes
51 52 53 |
# File 'lib/hanami/model/sql/entity/schema.rb', line 51 def call(attributes) schema.call(attributes) end |