module Malfunction::Malfunction::Core

Public Class Methods

new(context = nil, details: nil) click to toggle source
# File lib/malfunction/malfunction/core.rb, line 19
def initialize(context = nil, details: nil)
  self.context = context
  self.details = details
end

Public Instance Methods

problem() click to toggle source
# File lib/malfunction/malfunction/core.rb, line 14
def problem
  prototype_name.underscore.to_sym
end

Private Instance Methods

context=(context) click to toggle source
# File lib/malfunction/malfunction/core.rb, line 26
def context=(context)
  if context.nil?
    raise ArgumentError, "#{self.class.name} requires context" if contextualized? && !allow_nil_context?
  else
    raise ArgumentError, "#{self.class.name} is not contextualized" unless contextualized?
  end

  @context = context
end
details=(details) click to toggle source
# File lib/malfunction/malfunction/core.rb, line 36
def details=(details)
  raise ArgumentError, "details is invalid" unless details.nil? || details.respond_to?(:to_hash)

  @details = details.presence&.to_hash || {}
end