Class: Hanami::Entity::Schema::Definition::Dsl Private
- Inherits:
-
Object
- Object
- Hanami::Entity::Schema::Definition::Dsl
- 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 DSL
Class Method Summary collapse
- .build(&blk) ⇒ Object private
Instance Method Summary collapse
-
#attribute(name, type) ⇒ Object
private
Define an attribute.
-
#initialize(&blk) ⇒ Dsl
constructor
private
A new instance of Dsl.
- #to_h ⇒ Object private
Constructor Details
#initialize(&blk) ⇒ 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.
Returns a new instance of Dsl.
105 106 107 108 |
# File 'lib/hanami/entity/schema.rb', line 105 def initialize(&blk) @attributes = {} instance_eval(&blk) end |
Class Method Details
.build(&blk) ⇒ 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.
98 99 100 101 |
# File 'lib/hanami/entity/schema.rb', line 98 def self.build(&blk) attributes = new(&blk).to_h [attributes, Hanami::Model::Types::Coercible::Hash.schema(attributes)] end |
Instance Method Details
#attribute(name, type) ⇒ 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.
Define an attribute
136 137 138 |
# File 'lib/hanami/entity/schema.rb', line 136 def attribute(name, type) @attributes[name] = type end |
#to_h ⇒ 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.
142 143 144 |
# File 'lib/hanami/entity/schema.rb', line 142 def to_h @attributes end |