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.



182
183
184
185
186
187
# File 'lib/golem.rb', line 182

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.



181
182
183
# File 'lib/golem.rb', line 181

def event
  @event
end

#objectObject (readonly)

Returns the value of attribute object.



181
182
183
# File 'lib/golem.rb', line 181

def object
  @object
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



181
182
183
# File 'lib/golem.rb', line 181

def reasons
  @reasons
end

Instance Method Details

#human_explanationObject



189
190
191
192
193
# File 'lib/golem.rb', line 189

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



195
196
197
198
# File 'lib/golem.rb', line 195

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