Sha256: aa358441a8db7afbceee55842c7f1eef7d24df475f4aa94ca252ea3b9caee8bb

Contents?: true

Size: 564 Bytes

Versions: 1

Compression:

Stored size: 564 Bytes

Contents

module Saasable::ScopedController
  def self.included klass
    klass.send(:include, InstanceMethods)
    klass.class_eval do
      before_filter :fetch_current_saas
      before_filter :scope_models_by_saas
      
      helper_method :current_saas
    end
  end
  
  module InstanceMethods
    def current_saas
      @current_saas
    end

    private
      def fetch_current_saas
        @current_saas = Saasable::SaasDocument.saas_document.find_by_host!(request.host)
      end

      def scope_models_by_saas
        @current_saas.activate!
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
saasable-0.1.6 lib/saasable/scoped_controller.rb