Exception: Golem::ImpossibleEvent

Inherits:
StandardError
  • Object
show all
Defined in:
lib/golem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, event = nil, object = nil, reasons = nil) ⇒ ImpossibleEvent

Returns a new instance of ImpossibleEvent.



222
223
224
225
226
227
# File 'lib/golem.rb', line 222

def initialize(message, event = nil, object = nil, reasons = nil)
  @event = event
  @object = object
  @reasons = reasons
  super(message)
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



221
222
223
# File 'lib/golem.rb', line 221

def event
  @event
end

#objectObject (readonly)

Returns the value of attribute object.



221
222
223
# File 'lib/golem.rb', line 221

def object
  @object
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



221
222
223
# File 'lib/golem.rb', line 221

def reasons
  @reasons
end

Instance Method Details

#human_explanationObject



229
230
231
232
233
# File 'lib/golem.rb', line 229

def human_explanation
  event = [@event] unless @event.is_a?(Array)
  object = [@object] unless @object.is_a?(Array)
  "'#{event.collect{|ev|ev.name.to_s.humanize.upcase}.join("/")}' for #{object.collect{|ob|ob.to_s}.join("/")} failed"
end

#human_reasonsObject



235
236
237
238
# File 'lib/golem.rb', line 235

def human_reasons
  reasons = [@reasons] unless @reasons.is_a?(Array)
  reasons
end