#Copyright (c) 2008-9 Peter H. Boling of 9thBit LLC
#Released under the MIT license

module NinthBit
  module CustomEnvironments
    
    def self.included(base)
      base.extend(ClassMethods)
  
      base.cattr_accessor :local_environments
      base.local_environments = %w( development test )
    end

    module ClassMethods
      def consider_local?
        local_environments.include?(defined?(Rails) ? Rails.env : RAILS_ENV)
      end
    end
    
  end
end

#Copyright (c) 2008-9 Peter H. Boling of 9thBit LLC
#Released under the MIT license

module NinthBit
  module CustomEnvironments
    
    def self.included(base)
      base.extend(ClassMethods)
  
      base.cattr_accessor :local_environments
      base.local_environments = %w( development test )
    end

    module ClassMethods
      def consider_local?
        local_environments.include?(defined?(Rails) && Rails.respond_to?(:env) ? Rails.env : RAILS_ENV)
      end
    end
    
  end
end

Fix environment check for old versions of Rails
Fix environment check for old versions of Rails

In some versions of Rails, the Rails module exists but the env method on
it does not. Confirm that the Rails module exists _and_ responds to :env
before calling Rails.env instead of RAILS_ENV.
