Module: Dryv::Schema
- Defined in:
- lib/dryv/schema.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
144
145
146
|
# File 'lib/dryv/schema.rb', line 144
def method_missing(method)
attributes[method.to_sym]
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5
6
7
|
# File 'lib/dryv/schema.rb', line 5
def attributes
@attributes
end
|
#errors ⇒ Object
Returns the value of attribute errors.
5
6
7
|
# File 'lib/dryv/schema.rb', line 5
def errors
@errors
end
|
Instance Method Details
#[](key) ⇒ Object
14
15
16
|
# File 'lib/dryv/schema.rb', line 14
def [](key)
attributes[key.to_sym]
end
|
#initialize(params) ⇒ Object
7
8
9
10
11
|
# File 'lib/dryv/schema.rb', line 7
def initialize(params)
@errors = Dryv::Errors.new
@attributes = cast({ wrap: params }.deep_symbolize_keys[:wrap], schema)
JSON::Validator.validate!(schema, attributes)
end
|
#schema ⇒ Object
26
27
28
|
# File 'lib/dryv/schema.rb', line 26
def schema
raise NotImplemented
end
|
#valid? ⇒ Boolean
19
20
21
22
23
|
# File 'lib/dryv/schema.rb', line 19
def valid?
validate_attributes(attributes, schema)
validate_additional
!errors.any?
end
|