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.



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

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.



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

def event
  @event
end

#objectObject (readonly)

Returns the value of attribute object.



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

def object
  @object
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



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

def reasons
  @reasons
end

Instance Method Details

#human_explanationObject



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

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



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

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