Sha256: 70c7ece2bf813a49a42011757a2257870fc01c6f47250bb8f3d2356e86b0226f

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 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 = Saas::SaasDocument.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.4 lib/saasable/scoped_controller.rb