Class: Omnes::Subscriber::Adapter::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/omnes/subscriber/adapter/method.rb,
lib/omnes/subscriber/adapter/method/errors.rb

Overview

Builds a callback from a method of the instance

You can use an instance of this class as the adapter:

handle :foo, with: Adapter::Method.new(:foo)

However, you can short-circuit with a Symbol.

handle :foo, with: :foo

Defined Under Namespace

Classes: PrivateMethodSubscriptionAttemptError, UnknownMethodSubscriptionAttemptError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Method

Returns a new instance of Method.



24
25
26
# File 'lib/omnes/subscriber/adapter/method.rb', line 24

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/omnes/subscriber/adapter/method.rb', line 22

def name
  @name
end

Instance Method Details

#call(instance) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
33
# File 'lib/omnes/subscriber/adapter/method.rb', line 29

def call(instance)
  check_method(instance)

  instance.method(name)
end