Sha256: 094677051805176ac89cc3ced5e326ba2df3cf65d6614552fd044db2915722d7

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 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

1 entries across 1 versions & 1 rubygems

Version Path
rehearsal-0.9.0 lib/rehearsal.rb