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
- #errors ⇒ Object
- #to_hash ⇒ Object
- #valid? ⇒ Boolean (also: #ok?)
- #validate_schema(schema) ⇒ Object
- #values_at(*keys) ⇒ Object
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
33 34 35 |
# File 'lib/rest_my_case/context/base.rb', line 33 def errors @errors ||= self.class.error_class.new(self) end |
#to_hash ⇒ Object
25 26 27 |
# File 'lib/rest_my_case/context/base.rb', line 25 def to_hash Marshal.load Marshal.dump(attributes) end |
#valid? ⇒ Boolean Also known as: ok?
37 38 39 |
# File 'lib/rest_my_case/context/base.rb', line 37 def valid? errors.empty? end |
#validate_schema(schema) ⇒ Object
29 30 31 |
# File 'lib/rest_my_case/context/base.rb', line 29 def validate_schema(schema) self.class.schema_validator_class.new(self).validate(schema) end |
#values_at(*keys) ⇒ Object
21 22 23 |
# File 'lib/rest_my_case/context/base.rb', line 21 def values_at(*keys) attributes.values_at(*keys) end |