class Tengu::Double
Public Class Methods
new(identifier = nil, methods = {})
click to toggle source
# File lib/tengu/double.rb, line 3 def initialize(identifier = nil, methods = {}) @identifier = identifier methods.each do |message, value| define_singleton_method message, -> (*args) { _tengu_received[message] << args; value } end end
Public Instance Methods
_tengu_received()
click to toggle source
# File lib/tengu/double.rb, line 10 def _tengu_received @_tengu_received ||= Hash.new { |hash, key| hash[key] = [] } end
_tengu_received?(message, args = [])
click to toggle source
# File lib/tengu/double.rb, line 14 def _tengu_received?(message, args = []) if args.length > 0 _tengu_received[message] && _tengu_received[message].include?(args) else _tengu_received.keys.include?(message) end end