Class: Hanami::Entity::Schema::Definition Private
- Inherits:
-
Object
- Object
- Hanami::Entity::Schema::Definition
- Defined in:
- lib/hanami/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.
Schema definition
Defined Under Namespace
Classes: Dsl
Instance Method Summary collapse
-
#attribute?(name) ⇒ TrueClass, FalseClass
private
Check if the attribute is known.
-
#call(attributes) ⇒ Object
private
Process attributes.
-
#initialize(type = nil, &blk) ⇒ Hanami::Entity::Schema::Dsl
constructor
private
Instantiate a new DSL instance for an entity.
Constructor Details
#initialize(type = nil, &blk) ⇒ Hanami::Entity::Schema::Dsl
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.
Instantiate a new DSL instance for an entity
168 169 170 171 172 173 174 |
# File 'lib/hanami/entity/schema.rb', line 168 def initialize(type = nil, &blk) raise LocalJumpError unless block_given? @attributes, @schema = Dsl.build(type, &blk) @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
201 202 203 |
# File 'lib/hanami/entity/schema.rb', line 201 def attribute?(name) attributes.key?(name) end |
#call(attributes) ⇒ 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.
Process attributes
185 186 187 188 189 190 191 |
# File 'lib/hanami/entity/schema.rb', line 185 def call(attributes) schema.call(attributes) rescue Dry::Types::SchemaError => exception raise TypeError.new(exception.) rescue Dry::Types::MissingKeyError, Dry::Types::UnknownKeysError => exception raise ArgumentError.new(exception.) end |