Class: Deltacloud::Exceptions::ExceptionDef

Inherits:
Object
  • Object
show all
Defined in:
lib/deltacloud/drivers/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conditions, &block) ⇒ ExceptionDef

Returns a new instance of ExceptionDef.



129
130
131
132
133
# File 'lib/deltacloud/drivers/exceptions.rb', line 129

def initialize(conditions, &block)
  @conditions = conditions
  instance_eval(&block) if block_given?
  self
end

Instance Attribute Details

#conditionsObject (readonly)

Returns the value of attribute conditions.



126
127
128
# File 'lib/deltacloud/drivers/exceptions.rb', line 126

def conditions
  @conditions
end

#handler(e) ⇒ Object (readonly)

Returns the value of attribute handler.



127
128
129
# File 'lib/deltacloud/drivers/exceptions.rb', line 127

def handler
  @handler
end

#message(message) ⇒ Object

Returns the value of attribute message.



125
126
127
# File 'lib/deltacloud/drivers/exceptions.rb', line 125

def message
  @message
end

#status(code) ⇒ Object

Returns the value of attribute status.



124
125
126
# File 'lib/deltacloud/drivers/exceptions.rb', line 124

def status
  @status
end

Instance Method Details

#any?(e) ⇒ Boolean

Condition can be class or regexp

Returns:

  • (Boolean)


149
150
151
152
153
154
155
# File 'lib/deltacloud/drivers/exceptions.rb', line 149

def any?(e)
  @conditions.each do |c|
    return true if c.class == Class && e.class == c
    return true if c.class == Regexp && (e.class.name =~ c or e.message =~ c)
  end
  return false
end

#exception(handler) ⇒ Object



143
144
145
# File 'lib/deltacloud/drivers/exceptions.rb', line 143

def exception(handler)
  self.handler = handler
end