Class: JmeterPerf::Helpers::FallbackContextProxy
- Inherits:
-
Object
- Object
- JmeterPerf::Helpers::FallbackContextProxy
- Defined in:
- lib/jmeter_perf/helpers/fallback_content_proxy.rb
Constant Summary collapse
- NON_PROXIED_METHODS =
List of methods that should not be proxied.
[ :__id__, :__send__, :!, :"!=", :==, :equal?, :instance_eval, :instance_variable_get, :instance_variable_set, :instance_variables, :object_id, :remove_instance_variable ]
- NON_PROXIED_INSTANCE_VARIABLES =
List of instance variables that should not be proxied.
[ :@__fallback__, :@__receiver__ ]
Instance Method Summary collapse
-
#__proxy_method__(method) ⇒ Object
Proxies a method call to the primary receiver or fallback.
-
#id ⇒ Object
Returns the ID of the primary receiver.
-
#initialize(receiver, fallback) ⇒ FallbackContextProxy
constructor
Initializes a new FallbackContextProxy.
-
#instance_variables ⇒ Array<Symbol>
Returns the instance variables of the proxy, excluding non-proxied instance variables.
-
#method_missing(method) ⇒ Object
Handles method calls that are not explicitly defined in the proxy.
-
#respond_to_missing?(name, include_private) ⇒ Boolean
Checks if the proxy responds to a given method.
-
#sub ⇒ Object
Proxies the ‘sub` method call to the primary receiver or fallback.
Constructor Details
#initialize(receiver, fallback) ⇒ FallbackContextProxy
Initializes a new FallbackContextProxy.
39 40 41 42 |
# File 'lib/jmeter_perf/helpers/fallback_content_proxy.rb', line 39 def initialize(receiver, fallback) @__receiver__ = receiver @__fallback__ = fallback end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
Handles method calls that are not explicitly defined in the proxy.
80 81 82 |
# File 'lib/jmeter_perf/helpers/fallback_content_proxy.rb', line 80 def method_missing(method, ...) __proxy_method__(method, ...) end |
Instance Method Details
#__proxy_method__(method) ⇒ Object
Proxies a method call to the primary receiver or fallback.
90 91 92 93 94 |
# File 'lib/jmeter_perf/helpers/fallback_content_proxy.rb', line 90 def __proxy_method__(method, ...) @__receiver__.__send__(method.to_sym, ...) rescue NoMethodError @__fallback__.__send__(method.to_sym, ...) end |
#id ⇒ Object
Returns the ID of the primary receiver.
47 48 49 |
# File 'lib/jmeter_perf/helpers/fallback_content_proxy.rb', line 47 def id @__receiver__.__send__(:id) end |
#instance_variables ⇒ Array<Symbol>
Returns the instance variables of the proxy, excluding non-proxied instance variables.
62 63 64 |
# File 'lib/jmeter_perf/helpers/fallback_content_proxy.rb', line 62 def instance_variables super.map(&:to_sym) - NON_PROXIED_INSTANCE_VARIABLES end |
#respond_to_missing?(name, include_private) ⇒ Boolean
Checks if the proxy responds to a given method.
71 72 73 |
# File 'lib/jmeter_perf/helpers/fallback_content_proxy.rb', line 71 def respond_to_missing?(name, include_private) __proxy_method__(:respond_to?, name, include_private) end |
#sub ⇒ Object
Proxies the ‘sub` method call to the primary receiver or fallback.
55 56 57 |
# File 'lib/jmeter_perf/helpers/fallback_content_proxy.rb', line 55 def sub(...) __proxy_method__(:sub, ...) end |