Exception: ServiceObjects::Invalid

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/service_objects/invalid.rb

Overview

The exception to be risen by invalid services

Examples:

object = ServiceObjects::Base.new
fail ServiceObjects::Invalid.new object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#object#messages (readonly)

Invalid service object

Returns:


31
32
33
# File 'lib/service_objects/invalid.rb', line 31

def object
  @object
end

Class Method Details

.initialize(object) ⇒ ServiceObjects::Invalid

Constructs the exception for given service object

Examples:

object = ServiceObjects::Base.new
fail ServiceObjects::Invalid.new object

Parameters:

Returns:


22
23
24
25
# File 'lib/service_objects/invalid.rb', line 22

def initialize(object)
  @object = object
  validate
end

Instance Method Details

#messagesArray<ServiceObjects::Message>

The array of messages from the invalid #object

Returns:


36
37
38
# File 'lib/service_objects/invalid.rb', line 36

def messages
  Array(object.messages).flatten
end

#new(object) ⇒ ServiceObjects::Invalid

Constructs the exception for given service object

Examples:

object = ServiceObjects::Base.new
fail ServiceObjects::Invalid.new object

Parameters:

Returns:


22
23
24
25
# File 'lib/service_objects/invalid.rb', line 22

def initialize(object)
  @object = object
  validate
end