Sha256: 669e404883cdf09f2403ad255e769f2e620d0b1b0421fca49f395f3e6a72f6b0

Contents?: true

Size: 921 Bytes

Versions: 13

Compression:

Stored size: 921 Bytes

Contents

module Navi
  module Renderers
    class Base
      attr_accessor :context, :controller, :template

      def initialize(context)
        @context = context
        @controller = controller_from @context
        @template = template_from @controller
      end

      def render(collection)
        raise NotImplementedError
      end

      private

      # Pretty much lifted from 
      # https://github.com/andi/simple-navigation/blob/master/lib/simple_navigation/adapters/rails.rb
      def controller_from(context)
        context.respond_to?(:controller) ? context.controller : context
      end

      # Pretty much lifted from 
      # https://github.com/andi/simple-navigation/blob/master/lib/simple_navigation/adapters/rails.rb
      def template_from(controller)
        controller.respond_to?(:view_context) ? controller.view_context : controller.instance_variable_get(:@template)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
navi-0.1.4 lib/navi/renderers/base.rb
navi-0.1.3 lib/navi/renderers/base.rb
navi-0.0.17 lib/navi/renderers/base.rb
navi-0.0.16 lib/navi/renderers/base.rb
navi-0.0.15 lib/navi/renderers/base.rb
navi-0.0.14 lib/navi/renderers/base.rb
navi-0.0.13 lib/navi/renderers/base.rb
navi-0.0.12 lib/navi/renderers/base.rb
navi-0.0.11 lib/navi/renderers/base.rb
navi-0.0.10 lib/navi/renderers/base.rb
navi-0.0.9 lib/navi/renderers/base.rb
navi-0.0.6 lib/navi/renderers/base.rb
navi-0.0.2 lib/navi/renderers/base.rb