Class: Axn::Core::Flow::Handlers::BaseDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/axn/core/flow/handlers/base_descriptor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher: nil, handler: nil) ⇒ BaseDescriptor

Returns a new instance of BaseDescriptor.



12
13
14
15
16
# File 'lib/axn/core/flow/handlers/base_descriptor.rb', line 12

def initialize(matcher: nil, handler: nil)
  @matcher = matcher
  @handler = handler
  freeze
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



18
19
20
# File 'lib/axn/core/flow/handlers/base_descriptor.rb', line 18

def handler
  @handler
end

#matcherObject (readonly)

Returns the value of attribute matcher.



18
19
20
# File 'lib/axn/core/flow/handlers/base_descriptor.rb', line 18

def matcher
  @matcher
end

Class Method Details

.build(handler: nil, if: nil, unless: nil) ⇒ Object



28
29
30
31
# File 'lib/axn/core/flow/handlers/base_descriptor.rb', line 28

def self.build(handler: nil, if: nil, unless: nil, **)
  matcher = Matcher.build(if:, unless:)
  new(matcher:, handler:)
end

Instance Method Details

#matches?(action:, exception:) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/axn/core/flow/handlers/base_descriptor.rb', line 22

def matches?(action:, exception:)
  return true if static?

  @matcher.call(exception:, action:)
end

#static?Boolean

Returns:

  • (Boolean)


20
# File 'lib/axn/core/flow/handlers/base_descriptor.rb', line 20

def static? = @matcher.nil? || @matcher.static?