Class: RestMyCase::Context::Base
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- RestMyCase::Context::Base
- Includes:
- ActiveModel::Serialization
- Defined in:
- lib/rest_my_case/context/base.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.error_class ⇒ Object
13 14 15 |
# File 'lib/rest_my_case/context/base.rb', line 13 def self.error_class Errors::Base end |
.schema_validator_class ⇒ Object
17 18 19 |
# File 'lib/rest_my_case/context/base.rb', line 17 def self.schema_validator_class SchemaValidator::Base end |
Instance Method Details
#errors ⇒ Object
29 30 31 |
# File 'lib/rest_my_case/context/base.rb', line 29 def errors @errors ||= self.class.error_class.new(self) end |
#to_hash ⇒ Object
21 22 23 |
# File 'lib/rest_my_case/context/base.rb', line 21 def to_hash Marshal.load Marshal.dump(attributes) end |
#valid? ⇒ Boolean Also known as: ok?
33 34 35 |
# File 'lib/rest_my_case/context/base.rb', line 33 def valid? errors.empty? end |
#validate_schema(schema) ⇒ Object
25 26 27 |
# File 'lib/rest_my_case/context/base.rb', line 25 def validate_schema(schema) self.class.schema_validator_class.new(self).validate(schema) end |