Class: SwitchUser::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/switch_user/data_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, source) ⇒ Record

Returns a new instance of Record.



54
55
56
57
# File 'lib/switch_user/data_source.rb', line 54

def initialize(user, source)
  @user = user
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



52
53
54
# File 'lib/switch_user/data_source.rb', line 52

def source
  @source
end

#userObject (readonly)

Returns the value of attribute user.



52
53
54
# File 'lib/switch_user/data_source.rb', line 52

def user
  @user
end

Instance Method Details

#labelObject



59
60
61
# File 'lib/switch_user/data_source.rb', line 59

def label
  user.send(source.name)
end

#scopeObject



63
64
65
# File 'lib/switch_user/data_source.rb', line 63

def scope
  source.scope
end

#scope_idObject



67
68
69
# File 'lib/switch_user/data_source.rb', line 67

def scope_id
  "#{source.scope}_#{user.send(source.identifier)}"
end