Class: Fragmentary::SessionUser
- Inherits:
-
Object
- Object
- Fragmentary::SessionUser
- Defined in:
- lib/fragmentary/session_user.rb
Class Method Summary collapse
Instance Method Summary collapse
- #credentials ⇒ Object
-
#initialize(user_type, options = {}) ⇒ SessionUser
constructor
A new instance of SessionUser.
Constructor Details
#initialize(user_type, options = {}) ⇒ SessionUser
Returns a new instance of SessionUser.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fragmentary/session_user.rb', line 13 def initialize(user_type, ={}) if user = self.class.fetch(user_type) if user. != raise RangeError, "You can't redefine an existing SessionUser object: #{user_type.inspect}" else user end else @user_type = user_type @options = self.class.all.merge!({user_type => self}) end end |
Class Method Details
.all ⇒ Object
5 6 7 |
# File 'lib/fragmentary/session_user.rb', line 5 def self.all @@all ||= Hash.new end |
.fetch(key) ⇒ Object
9 10 11 |
# File 'lib/fragmentary/session_user.rb', line 9 def self.fetch(key) all[key] end |
Instance Method Details
#credentials ⇒ Object
27 28 29 |
# File 'lib/fragmentary/session_user.rb', line 27 def credentials [:credentials] end |