Sha256: f23c1724dbba4e54b85d8d0be321aedf184dbeeeb6b181ab4d94b52c54d8274f
Contents?: true
Size: 665 Bytes
Versions: 3
Compression:
Stored size: 665 Bytes
Contents
# Base Module for ViewModels. # module ViewModels # Extracts controllers for a living from unsuspecting views. # class ContextExtractor # The context # attr_reader :context # Initialize the Context extractor # @param [ActionController, ActionMailer, ActionView] context Some render context # def initialize context @context = context end # Extracts a controller from the context. # @return [ActionController] an instance of action controller # def extract context = self.context context.respond_to?(:controller) ? context.send(:controller) : context end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
view_models-4.0.1 | lib/view_models/context_extractor.rb |
view_models-3.0.1 | lib/view_models/context_extractor.rb |
view_models-3.0.0 | lib/view_models/context_extractor.rb |