module Oha
Main Module that defines all the behaviour that will be added to a UseCase
Constants
- VERSION
Public Class Methods
included(base)
click to toggle source
# File lib/oha.rb, line 9 def self.included(base) base.extend ClassMethods end
new(*args) { |binder| ... }
click to toggle source
# 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
Public Instance Methods
set_callback(event, callable)
click to toggle source
# File lib/oha.rb, line 23 def set_callback(event, callable) @callbacks[event.to_sym] = callable self end
trigger(event, payload = {})
click to toggle source
# File lib/oha.rb, line 28 def trigger(event, payload = {}) callback = @callbacks.fetch(event.to_sym) { raise Oha::Errors::EventNotDefined } callback.call(payload) end