Sha256: 8f49147be1c36cbfdb7ac3fbf2645810dca394f67325e5b2ee383d3068be0092

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

require "sandbox_assets/test_asset"

module SandboxAssets
  class BaseController < ActionController::Base
    before_filter :find_tests
    before_filter :extract_template_from_params
    before_filter :render_template

    # additional before_filters can use this
    def template=(template)
      @template = template
    end

    protected

    def find_tests
      @tests = TestAsset.find_tests(params)
    end

    def extract_template_from_params
      @template ||= params[:template] unless cfg.disable_template_param
    end

    def render_template
      render @template if template
    end

    def template
      @template ||= cfg.template
    end

    def cfg
      @cfg ||= Engine.config.sandbox_assets
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-sandbox-assets-0.0.3 app/controllers/sandbox_assets/base_controller.rb
rails-sandbox-assets-0.0.2 app/controllers/sandbox_assets/base_controller.rb