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



10
11
12
# File 'lib/rest_my_case/context/base.rb', line 10

def self.error_class
  Errors::Base
end

Instance Method Details

#errorsObject



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

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

#to_hashObject



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

def to_hash
  Marshal.load Marshal.dump(attributes)
end

#valid?Boolean Also known as: ok?

Returns:

  • (Boolean)


22
23
24
# File 'lib/rest_my_case/context/base.rb', line 22

def valid?
  errors.empty?
end