Module: HashAuth

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Defined in:
lib/hash-auth.rb,
lib/hash-auth/client.rb,
lib/hash-auth/config.rb,
lib/hash-auth/railtie.rb,
lib/hash-auth/version.rb,
lib/hash-auth/strategies.rb,
lib/hash-auth/controllers.rb,
lib/hash-auth/web_request.rb,
lib/hash-auth/strategies/base.rb,
lib/hash-auth/strategies/default.rb,
lib/hash-auth/controllers/helpers.rb

Defined Under Namespace

Modules: ClassMethods, Controllers, Strategies Classes: Client, Config, InstallGenerator, MissingConfiguration, Railtie, StrategyGenerator, WebRequest

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.clientsObject



24
25
26
# File 'lib/hash-auth/config.rb', line 24

def self.clients
  @clients
end

.clients=(val) ⇒ Object



20
21
22
# File 'lib/hash-auth/config.rb', line 20

def self.clients=(val)
  @clients = val
end

.configurationObject



12
13
14
# File 'lib/hash-auth/config.rb', line 12

def self.configuration
  @config || (raise MissingConfiguration.new)
end

.configuration=(val) ⇒ Object



16
17
18
# File 'lib/hash-auth/config.rb', line 16

def self.configuration=(val)
  @config = val
end

.configure(&block) ⇒ Object



8
9
10
# File 'lib/hash-auth/config.rb', line 8

def self.configure(&block)
  @config = Config::Builder.new(&block).build
end

.configured?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/hash-auth.rb', line 22

def self.configured?
  @config.present?
end

.find_client(name) ⇒ Object



28
29
30
# File 'lib/hash-auth/config.rb', line 28

def self.find_client(name)
  @clients.select{|c| c.customer_identifier == name}[0]
end

.find_strategy(name) ⇒ Object



40
41
42
43
44
# File 'lib/hash-auth/config.rb', line 40

def self.find_strategy(name)
  strategy = self.strategies.select{|s| s.identifier == name}[0]
  raise "Strategy specified with name = :#{name} does not exist" unless strategy
  strategy
end

.strategiesObject



32
33
34
35
36
37
38
# File 'lib/hash-auth/config.rb', line 32

def self.strategies
  return @strategies if @strategies
  
  constants = HashAuth::Strategies.constants.select { |c| Class === HashAuth::Strategies.const_get(c) }
  @strategies = constants.map{ |c| HashAuth::Strategies.const_get(c) }.select{|c| c != HashAuth::Strategies::Base}
  @strategies
end