Class: Capybara::AsyncRunner::Env
- Inherits:
-
Object
- Object
- Capybara::AsyncRunner::Env
- Defined in:
- lib/capybara/async_runner/env.rb
Overview
Internal class for building environment for rendering .js.erb code
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#responders ⇒ Object
readonly
Returns the value of attribute responders.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
-
#initialize(uuid, data, responders) ⇒ Env
constructor
For responders:.
-
#js_environment ⇒ Object
(also: #js)
Returns a js environment that can be used for fetching data from the code on-the-fly.
-
#local_binding ⇒ Binding
Returns local binding that is used for rendering (ERB.new(template).result(binding)).
-
#method_missing(method_name, *args) ⇒ Object
Delegates a method to responder.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(uuid, data, responders) ⇒ Env
For responders:
11 12 13 14 15 |
# File 'lib/capybara/async_runner/env.rb', line 11 def initialize(uuid, data, responders) @uuid = uuid @data = data @responders = responders end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
Delegates a method to responder
39 40 41 42 43 44 45 |
# File 'lib/capybara/async_runner/env.rb', line 39 def method_missing(method_name, *args) if responders.include?(method_name) response_method_for(method_name, *args) else super end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
16 17 18 |
# File 'lib/capybara/async_runner/env.rb', line 16 def data @data end |
#responders ⇒ Object (readonly)
Returns the value of attribute responders.
16 17 18 |
# File 'lib/capybara/async_runner/env.rb', line 16 def responders @responders end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
16 17 18 |
# File 'lib/capybara/async_runner/env.rb', line 16 def uuid @uuid end |
Instance Method Details
#js_environment ⇒ Object Also known as: js
Returns a js environment that can be used for fetching data from the code on-the-fly
25 26 27 28 29 |
# File 'lib/capybara/async_runner/env.rb', line 25 def js_environment Hash.new do |h, k| k.to_s end end |
#local_binding ⇒ Binding
Returns local binding that is used for rendering (ERB.new(template).result(binding))
56 57 58 |
# File 'lib/capybara/async_runner/env.rb', line 56 def local_binding binding end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
48 49 50 |
# File 'lib/capybara/async_runner/env.rb', line 48 def respond_to_missing?(method_name, include_private = false) super || responders.include?(method_name) end |