Class: Factbase::Spy::SpyFact

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/spy.rb

Overview

A fact that is spying.

Instance Method Summary collapse

Constructor Details

#initialize(fact, key, caught) ⇒ SpyFact

Returns a new instance of SpyFact.



63
64
65
66
67
# File 'lib/factbase/spy.rb', line 63

def initialize(fact, key, caught)
  @fact = fact
  @key = key
  @caught = caught
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



69
70
71
72
# File 'lib/factbase/spy.rb', line 69

def method_missing(*args)
  @caught << args[1] if args[0].to_s == "#{@key}="
  @fact.method_missing(*args)
end

Instance Method Details

#respond_to?(method, include_private = false) ⇒ Boolean

rubocop:disable Style/OptionalBooleanParameter

Returns:

  • (Boolean)


75
76
77
78
# File 'lib/factbase/spy.rb', line 75

def respond_to?(method, include_private = false)
  # rubocop:enable Style/OptionalBooleanParameter
  @fact.respond_to?(method, include_private)
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/factbase/spy.rb', line 80

def respond_to_missing?(method, include_private = false)
  @fact.respond_to_missing?(method, include_private)
end