Class: RestMyCase::Context::Base

Inherits:
OpenStruct
  • Object
show all
Includes:
ActiveModel::Serialization
Defined in:
lib/rest_my_case/context/base.rb

Direct Known Subclasses

Status

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.error_classObject



15
16
17
# File 'lib/rest_my_case/context/base.rb', line 15

def self.error_class
  Errors::Base
end

.schema_validator_classObject



19
20
21
# File 'lib/rest_my_case/context/base.rb', line 19

def self.schema_validator_class
  SchemaValidator::Base
end

Instance Method Details

#errorsObject



31
32
33
# File 'lib/rest_my_case/context/base.rb', line 31

def errors
  @errors ||= self.class.error_class.new(self)
end

#to_hashObject



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?

Returns:

  • (Boolean)


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