Sha256: a0bf52633af7f21cdffda2d0b4a141e0bfb7703d9d8ee114e82157e14b9d9a22

Contents?: true

Size: 540 Bytes

Versions: 3

Compression:

Stored size: 540 Bytes

Contents

# Base Module for ViewModels.
#
module ViewModels
  
  # Extracts controllers for a living from unsuspecting views.
  #
  # Note: This is actually only needed in Rails. In Padrino, the context is always the app.
  #
  class ContextExtractor
    
    attr_reader :context
    
    def initialize context
      @context = context
    end
    
    # Extracts a controller from the context.
    #
    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-2.0.1 lib/shared/lib/view_models/context_extractor.rb
view_models-2.0.0.ruby19 lib/shared/lib/view_models/context_extractor.rb
view_models-2.0.0 lib/shared/lib/view_models/context_extractor.rb