Sha256: d84187b94f35b2b8b4783f2ce1b78a7ed8b7b06335f593415912eea1c2afa648
Contents?: true
Size: 996 Bytes
Versions: 5
Compression:
Stored size: 996 Bytes
Contents
require "forwardable" require "method_callbacks/definer" require "method_callbacks/executor" require "method_callbacks/locker" module MethodCallbacks class Method extend Forwardable ALIAS_PREFIX = "__method_callback_alias_to_original" attr_reader :name def_delegators :definer, :define, :define_with_block def_delegators :locker, :lock!, :locked?, :unlock! def initialize(name) @name = name end def ==(other) self.name == other.name end def alias "#{ALIAS_PREFIX}_#{name}" end def callbacks(type) @_callbacks ||= {} @_callbacks[type] ||= [] end def execute(type, object) block_given? ? executor(type, object).execute(&Proc.new) : executor(type, object).execute end private def executor(type, object) Executor.new(self, type, object) end def definer @_definer ||= Definer.new(self) end def locker @_method_lock ||= Locker.new end end end
Version data entries
5 entries across 5 versions & 1 rubygems