Class: ViewModels::ContextExtractor
- Inherits:
-
Object
- Object
- ViewModels::ContextExtractor
- Defined in:
- lib/view_models/context_extractor.rb
Overview
Extracts controllers for a living from unsuspecting views.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
The context.
Instance Method Summary collapse
-
#extract ⇒ ActionController
Extracts a controller from the context.
-
#initialize(context) ⇒ ContextExtractor
constructor
Initialize the Context extractor.
Constructor Details
#initialize(context) ⇒ ContextExtractor
Initialize the Context extractor
16 17 18 |
# File 'lib/view_models/context_extractor.rb', line 16 def initialize context @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
The context
11 12 13 |
# File 'lib/view_models/context_extractor.rb', line 11 def context @context end |
Instance Method Details
#extract ⇒ ActionController
Extracts a controller from the context.
23 24 25 26 |
# File 'lib/view_models/context_extractor.rb', line 23 def extract context = self.context context.respond_to?(:controller) ? context.send(:controller) : context end |