<commit_before>module Saasable::Railties
  module Helpers
    def self.included klass
      klass.send(:include, InstanceMethods)
      klass.class_eval do
        helper_method :current_saas
      end
    end
  
    module InstanceMethods
      def current_saas
        @current_saas ||= request.env[:saasable][:current_saas]
      end
    end
  end
end<commit_msg>Improve helpers for more funcionality<commit_after>module Saasable::Railties
  module Helpers
    def self.included klass
      klass.extend ClassMethods
      klass.send(:include, InstanceMethods)
      klass.class_eval do
        helper_method :current_saas
        
        before_filter :_redirect_if_saas_not_found
        saas_not_found_redirect_to "/404.html"
        
        private
          def _skip_saasable
            current_saas.deactivate! if current_saas
          end
      end
    end
    
    module ClassMethods
      def saas_not_found_redirect_to path_or_url
        self.class_eval <<-METHOD, __FILE__, __LINE__ + 1
          private
            def _redirect_if_saas_not_found
              unless current_saas
                redirect_to "#{path_or_url}"
              end
            end
        METHOD
      end
      
      def skip_saasable options
        skip_before_filter :_redirect_if_saas_not_found, options
        before_filter :_skip_saasable, options
      end
    end
  
    module InstanceMethods
      def current_saas
        @current_saas ||= request.env[:saasable][:current_saas]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.047337278106508875, 'fraction_numerical': 0.0026298487836949377, 'mean_word_length': 2.1252566735112937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7298200', 'n_tokens_mistral': 460, 'n_tokens_neox': 458, 'n_words': 98}