Class: Hector::Identity

Inherits:
Object
  • Object
show all
Defined in:
lib/hector/identity.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ Identity

Returns a new instance of Identity.



15
16
17
# File 'lib/hector/identity.rb', line 15

def initialize(username)
  @username = username
end

Class Attribute Details

.adapterObject

Returns the value of attribute adapter.



6
7
8
# File 'lib/hector/identity.rb', line 6

def adapter
  @adapter
end

Instance Attribute Details

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/hector/identity.rb', line 3

def username
  @username
end

Class Method Details

.authenticate(username, password) ⇒ Object



8
9
10
11
12
# File 'lib/hector/identity.rb', line 8

def authenticate(username, password)
  adapter.authenticate(username, password) do |authenticated|
    yield authenticated ? new(username) : nil
  end
end

Instance Method Details

#==(identity) ⇒ Object



19
20
21
# File 'lib/hector/identity.rb', line 19

def ==(identity)
  Identity.adapter.normalize(username) == Identity.adapter.normalize(identity.username)
end