Class: Effigy::Selection
Overview
Proxy class for performing transformations with a set selection.
Selections are created and returned when calling View#find without a block. Any methods called on the Selection will be forwarded to the given view with the given selector inserted at the front of the argument list.
All methods should return the Selection itself, so transformation methods can be chained on a selection.
Normally, Selections are not instantiated directly, but by calling View#find.
Instance Method Summary collapse
-
#initialize(view, selector) ⇒ Selection
constructor
Creates a selection over the given view using the given selector.
-
#method_missing(method, *args, &block) ⇒ Selection
Undefined methods are forwarded to the view with the selector inserted at the beginning of the argument list.
Constructor Details
#initialize(view, selector) ⇒ Selection
Creates a selection over the given view using the given selector.
24 25 26 27 |
# File 'lib/effigy/selection.rb', line 24 def initialize(view, selector) @view = view @selector = selector end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Selection
Undefined methods are forwarded to the view with the selector inserted at the beginning of the argument list. The Selection is then returned for chaining.
34 35 36 37 |
# File 'lib/effigy/selection.rb', line 34 def method_missing(method, *args, &block) @view.send(method, @selector, *args, &block) self end |