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 |
# File 'lib/model/model.rb', line 19 def to clazz clazz.new attributes end |
#to_json ⇒ Object
23 24 25 |
# File 'lib/model/model.rb', line 23 def to_json attributes end |
#validate ⇒ Object
15 16 17 |
# File 'lib/model/model.rb', line 15 def validate @@validation_schema.call(attributes). end |