Class: WisperInteractor::Base

Inherits:
Object
  • Object
show all
Includes:
Interactor, Wisper::Publisher
Defined in:
lib/wisper_interactor/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instructionsObject



41
42
43
# File 'lib/wisper_interactor/base.rb', line 41

def self.instructions
  @instructions
end

.instructions=(value) ⇒ Object



37
38
39
# File 'lib/wisper_interactor/base.rb', line 37

def self.instructions=(value)
  @instructions = value
end

.on_failure(&blk) ⇒ Object



13
14
15
# File 'lib/wisper_interactor/base.rb', line 13

def self.on_failure(&blk)
  self.on_failure_callback = blk
end

.on_failure_callbackObject



33
34
35
# File 'lib/wisper_interactor/base.rb', line 33

def self.on_failure_callback
  @on_failure_callback
end

.on_failure_callback=(value) ⇒ Object



29
30
31
# File 'lib/wisper_interactor/base.rb', line 29

def self.on_failure_callback=(value)
  @on_failure_callback = value
end

.on_success(&blk) ⇒ Object



9
10
11
# File 'lib/wisper_interactor/base.rb', line 9

def self.on_success(&blk)
  self.on_success_callback = blk
end

.on_success_callbackObject



25
26
27
# File 'lib/wisper_interactor/base.rb', line 25

def self.on_success_callback
  @on_success_callback
end

.on_success_callback=(value) ⇒ Object



21
22
23
# File 'lib/wisper_interactor/base.rb', line 21

def self.on_success_callback=(value)
  @on_success_callback = value
end

.perform(&blk) ⇒ Object



17
18
19
# File 'lib/wisper_interactor/base.rb', line 17

def self.perform(&blk)
  self.instructions = blk
end

.subscribe(subscriber, **options) ⇒ Object



49
50
51
# File 'lib/wisper_interactor/base.rb', line 49

def self.subscribe(subscriber, **options)
  self.subscribers << [ subscriber, options ]
end

.subscribersObject



45
46
47
# File 'lib/wisper_interactor/base.rb', line 45

def self.subscribers
  @subscribers ||= []
end

Instance Method Details

#callObject



60
61
62
# File 'lib/wisper_interactor/base.rb', line 60

def call
  execute :instructions
end

#run!Object

Override Interactor#run!



55
56
57
58
# File 'lib/wisper_interactor/base.rb', line 55

def run!
  subscribe_listeners
  perform_instructions
end