Sha256: b13c0b787565b1aa942bd5c60b289f176cc1ebfcb512381cea55f1bc2e55801d

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8

# Selects the client by hostname
module Goldencobra
  module SelectCurrentClient
    def self.included(base)
      base.class_eval do
        include InstanceMethods
        extend ClassMethods
        before_filter :determine_client
        before_filter :add_view_path_for_client
        helper_method :current_client
      end
    end

    module InstanceMethods
      def current_client
        @current_client
      end

      private

      def determine_client
        @current_client = Goldencobra::Domain.find_by_hostname(request.host) || Goldencobra::Domain.first
        Goldencobra::Domain.current = @current_client
        Goldencobra::Article::LiquidParser["current_client"] = @current_client
      end

      def add_view_path_for_client
        if @current_client.present?
          @_lookup_context.view_paths.unshift("app/views/#{@current_client.client}")
        end
      end
    end

    module ClassMethods
    end
  end
end

::ActionController::Base.send :include, Goldencobra::SelectCurrentClient

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
goldencobra-2.3.4 lib/goldencobra/select_current_client.rb
goldencobra-2.3.3 lib/goldencobra/select_current_client.rb
goldencobra-1.4.27 lib/goldencobra/select_current_client.rb
goldencobra-1.4.0 lib/goldencobra/select_current_client.rb
goldencobra-1.3.4 lib/goldencobra/select_current_client.rb