Sha256: 1a637808bc4537b092b09984cbe7c239bba3eba21959188ceb9eddfb67c4af85

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module MultiSync
  module Environment
    # Retrieves the current MultiSync environment
    #
    # @return [String] the current environment
    def environment
      @environment ||= ENV['MULTI_SYNC_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
    end
    alias_method :env, :environment

    # Sets the current MultiSync environment
    #
    # @param [String|Symbol] env the environment symbol
    def environment=(e)
      @environment = e.to_s
    end
    alias_method :env=, :environment=

    # Determines if we are in a particular environment
    #
    # @return [Boolean] true if current environment matches, false otherwise
    def environment?(e)
      environment == e.to_s
    end
    alias_method :env?, :environment?

    # Create methods for the environment shorthands
    [:test, :development, :staging, :production].each do |e|
      # Determines if we are in a particular environment
      #
      # @return [Boolean] true if current environment matches, false otherwise
      define_method "#{e}?" do
        environment? e
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
multi_sync-0.0.4 lib/multi_sync/environment.rb
multi_sync-0.0.3 lib/multi_sync/environment.rb
multi_sync-0.0.2 lib/multi_sync/environment.rb
multi_sync-0.0.1 lib/multi_sync/environment.rb