Class: AutomationObject::State::ElementProxy

Inherits:
Proxy::Proxy show all
Defined in:
lib/automation_object/state/element_proxy.rb

Overview

Proxy class to allow for usage of hooks

Instance Method Summary collapse

Constructor Details

#initialize(composite, element) ⇒ ElementProxy

Returns a new instance of ElementProxy



9
10
11
12
# File 'lib/automation_object/state/element_proxy.rb', line 9

def initialize(composite, element)
  @composite = composite
  @subject = element
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_symbol, *args, &block) ⇒ Object

Overiding base method to run possible hooks



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/automation_object/state/element_proxy.rb', line 15

def method_missing(method_symbol, *args, &block)
  # Run before hook if needed
  @composite.method_hooks[method_symbol].before if @composite.method_hook?(method_symbol)

  subject_return = @subject.send(method_symbol, *args, &block)

  # Run after hook if needed
  @composite.method_hooks[method_symbol].after if @composite.method_hook?(method_symbol)

  subject_return
end

Instance Method Details

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

Returns:

  • (Boolean)


27
28
29
# File 'lib/automation_object/state/element_proxy.rb', line 27

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