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.
21 22 23 24 |
# File 'lib/switch_user/user_loader.rb', line 21 def initialize(scope, id) self.scope = scope self.id = id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/switch_user/user_loader.rb', line 6 def id @id end |
#scope ⇒ Object
Returns the value of attribute scope.
5 6 7 |
# File 'lib/switch_user/user_loader.rb', line 5 def scope @scope end |
Class Method Details
.prepare(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/switch_user/user_loader.rb', line 8 def self.prepare(*args) = args. if [:scope_identifier] [:scope_identifier] =~ /^(.*)_([^_]+)$/ scope = Regexp.last_match(1) id = Regexp.last_match(2) else scope, id = args end new(scope, id) end |
Instance Method Details
#user ⇒ Object
26 27 28 |
# File 'lib/switch_user/user_loader.rb', line 26 def user user_class.where(column_name => id).first end |