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(&blk) ⇒ Hanami::Entity::Schema::Dsl
constructor
private
Instantiate a new DSL instance for an entity.
Constructor Details
#initialize(&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
155 156 157 158 159 160 |
# File 'lib/hanami/entity/schema.rb', line 155 def initialize(&blk) raise LocalJumpError unless block_given? @attributes, @schema = Dsl.build(&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
184 185 186 |
# File 'lib/hanami/entity/schema.rb', line 184 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
170 171 172 173 174 |
# File 'lib/hanami/entity/schema.rb', line 170 def call(attributes) schema.call(attributes) rescue Dry::Types::SchemaError => e raise TypeError.new(e.) end |