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
15 16 17 |
# File 'lib/rest_my_case/context/base.rb', line 15 def self.error_class Errors::Base end |
.schema_validator_class ⇒ Object
19 20 21 |
# File 'lib/rest_my_case/context/base.rb', line 19 def self.schema_validator_class SchemaValidator::Base end |
Instance Method Details
#errors ⇒ Object
31 32 33 |
# File 'lib/rest_my_case/context/base.rb', line 31 def errors @errors ||= self.class.error_class.new(self) end |
#to_hash ⇒ Object
23 24 25 |
# File 'lib/rest_my_case/context/base.rb', line 23 def to_hash Marshal.load Marshal.dump(attributes) end |
#valid? ⇒ Boolean Also known as: ok?
35 36 37 |
# File 'lib/rest_my_case/context/base.rb', line 35 def valid? errors.empty? end |
#validate_schema(schema) ⇒ Object
27 28 29 |
# File 'lib/rest_my_case/context/base.rb', line 27 def validate_schema(schema) self.class.schema_validator_class.new(self).validate(schema) end |