Sha256: 2fcad76c9d2754a98e34e02ae5bec5198582dfb6a2a84342d5862baf90eec1dd

Contents?: true

Size: 718 Bytes

Versions: 2

Compression:

Stored size: 718 Bytes

Contents

require "rehearsal/version"
require "rehearsal/engine"

module Rehearsal
  def self.included(base)
    base.extend ClassMethods
    base.helper_method :staging?
    base.before_filter :require_http_basic_auth
  end

  module ClassMethods
    def rehearse_with(options = {})
      class_eval do
        define_method(:username) do
          options[:username]
        end

        define_method(:password) do
          options[:password]
        end
      end
    end
  end

  private
  def require_http_basic_auth
    authenticate_or_request_with_http_basic do |username, password|
      username == self.username && password == self.password
    end if staging?
  end

  def staging?
    Rails.env.staging?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rehearsal-0.9.2 lib/rehearsal.rb
rehearsal-0.9.1 lib/rehearsal.rb