Class: Tengu::Double
- Inherits:
-
Object
- Object
- Tengu::Double
- Defined in:
- lib/tengu/double.rb
Instance Method Summary collapse
- #_tengu_received ⇒ Object
- #_tengu_received?(message, args = []) ⇒ Boolean
-
#initialize(identifier = nil, methods = {}) ⇒ Double
constructor
A new instance of Double.
Constructor Details
#initialize(identifier = nil, methods = {}) ⇒ Double
Returns a new instance of Double.
3 4 5 6 7 8 |
# File 'lib/tengu/double.rb', line 3 def initialize(identifier = nil, methods = {}) @identifier = identifier methods.each do |, value| define_singleton_method , -> (*args) { _tengu_received[] << args; value } end end |
Instance Method Details
#_tengu_received ⇒ Object
10 11 12 |
# File 'lib/tengu/double.rb', line 10 def _tengu_received @_tengu_received ||= Hash.new { |hash, key| hash[key] = [] } end |
#_tengu_received?(message, args = []) ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'lib/tengu/double.rb', line 14 def _tengu_received?(, args = []) if args.length > 0 _tengu_received[] && _tengu_received[].include?(args) else _tengu_received.keys.include?() end end |