Module: Excom::Plugins::Sentry::ClassMethods

Defined in:
lib/excom/plugins/sentry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_sentry_classObject



67
68
69
# File 'lib/excom/plugins/sentry.rb', line 67

def _sentry_class
  @_sentry_class ||= "#{name}Sentry"
end

Instance Method Details

#inherited(service_class) ⇒ Object



43
44
45
46
# File 'lib/excom/plugins/sentry.rb', line 43

def inherited(service_class)
  super
  service_class.sentry_class(_sentry_class)
end

#sentry(delegate: [], &block) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/excom/plugins/sentry.rb', line 71

def sentry(delegate: [], &block)
  (plugins[:sentry].options[:delegate] ||= []).concat(delegate).uniq!

  if const_defined?(:Sentry)
    const_get(:Sentry).class_eval(&block)
  else
    @_sentry_class = @sentry_class = Class.new(Sentry, &block)
    @sentry_class.service_class = self
    const_set(:Sentry, @_sentry_class)
  end
end

#sentry_class(klass = UNDEFINED) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/excom/plugins/sentry.rb', line 48

def sentry_class(klass = UNDEFINED)
  return self._sentry_class = klass unless klass == UNDEFINED
  return @sentry_class if defined? @sentry_class

  @sentry_class =
    if _sentry_class.is_a?(String)
      return _sentry_class.constantize if _sentry_class.respond_to?(:constantize)

      names = _sentry_class.split('::'.freeze)
      names.shift if names.first.empty?
      names.reduce(Object){ |obj, name| obj.const_get(name) }
    else
      _sentry_class
    end

  @sentry_class.service_class = self
  @sentry_class
end