Module: Oha
- Defined in:
- lib/oha.rb,
lib/oha/binder.rb,
lib/oha/version.rb,
lib/oha/errors/event_not_defined.rb,
lib/oha/errors/no_block_given_error.rb
Overview
Main Module that defines all the behaviour that will be added to a UseCase
Defined Under Namespace
Modules: ClassMethods, Errors
Classes: Binder
Constant Summary
collapse
- VERSION =
'0.1.0'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
9
10
11
|
# File 'lib/oha.rb', line 9
def self.included(base)
base.extend ClassMethods
end
|
Instance Method Details
#initialize(*args) {|@binder| ... } ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/oha.rb', line 13
def initialize(*args)
raise Oha::Errors::NoBlockGivenError unless block_given?
@binder = Oha::Binder.new(self)
@callbacks = {}
@params = args
yield @binder
self
end
|
#set_callback(event, callable) ⇒ Object
23
24
25
26
|
# File 'lib/oha.rb', line 23
def set_callback(event, callable)
@callbacks[event.to_sym] = callable
self
end
|
#trigger(event, payload = {}) ⇒ Object
28
29
30
31
|
# File 'lib/oha.rb', line 28
def trigger(event, payload = {})
callback = @callbacks.fetch(event.to_sym) { raise Oha::Errors::EventNotDefined }
callback.call(payload)
end
|