Class: Model
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Model
- Defined in:
- lib/model/model.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.validates(&blk) ⇒ Object
11 12 13 |
# File 'lib/model/model.rb', line 11 def self.validates &blk @@validation_schema = Dry::Validation.Schema &blk end |
Instance Method Details
#to(clazz) ⇒ Object
19 20 21 22 |
# File 'lib/model/model.rb', line 19 def to clazz new_attributes = attributes.merge(clazz.different_attributes(attributes, self.class)) clazz.new new_attributes end |
#to_json ⇒ Object
24 25 26 |
# File 'lib/model/model.rb', line 24 def to_json attributes end |
#validate ⇒ Object
15 16 17 |
# File 'lib/model/model.rb', line 15 def validate @@validation_schema.call(attributes). end |