Class: Mortymer::Model
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Mortymer::Model
show all
- Includes:
- Moldeable, Types
- Defined in:
- lib/mortymer/model.rb
Overview
A base model for defining schemas
Constant Summary
Constants included
from Types
Types::UploadedFile, Types::UploadedFiles
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.json_schema ⇒ Object
14
15
16
|
# File 'lib/mortymer/model.rb', line 14
def self.json_schema
Generator.new.from_struct(self)
end
|
.structify(params) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/mortymer/model.rb', line 18
def self.structify(params)
if params.instance_of?(self.class)
params
else
call(params)
end
end
|
Instance Method Details
#[](key) ⇒ Object
26
27
28
|
# File 'lib/mortymer/model.rb', line 26
def [](key)
public_send(key)
end
|
#key?(attr) ⇒ Boolean
Also known as:
has_key?
30
31
32
|
# File 'lib/mortymer/model.rb', line 30
def key?(attr)
attributes.key?(attr.to_sym)
end
|