Class: SwitchUser::UserLoader
- Inherits:
-
Object
- Object
- SwitchUser::UserLoader
- Defined in:
- lib/switch_user/user_loader.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(scope, id) ⇒ UserLoader
constructor
A new instance of UserLoader.
- #user ⇒ Object
Constructor Details
#initialize(scope, id) ⇒ UserLoader
Returns a new instance of UserLoader.
18 19 20 21 |
# File 'lib/switch_user/user_loader.rb', line 18 def initialize(scope, id) self.scope = scope self.id = id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/switch_user/user_loader.rb', line 4 def id @id end |
#scope ⇒ Object
Returns the value of attribute scope.
3 4 5 |
# File 'lib/switch_user/user_loader.rb', line 3 def scope @scope end |
Class Method Details
.prepare(*args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/switch_user/user_loader.rb', line 6 def self.prepare(*args) = args. if [:scope_identifier] [:scope_identifier] =~ /^(.*)_([^_]+)$/ scope, id = $1, $2 else scope, id = args end new(scope, id) end |
Instance Method Details
#user ⇒ Object
23 24 25 |
# File 'lib/switch_user/user_loader.rb', line 23 def user user_class.where(column_name => id).first end |