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.



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

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

Instance Attribute Details

#source ⇒ Object (readonly)

Returns the value of attribute source.



48
49
50
# File 'lib/switch_user/data_source.rb', line 48

def source
  @source
end

#user ⇒ Object (readonly)

Returns the value of attribute user.



48
49
50
# File 'lib/switch_user/data_source.rb', line 48

def user
  @user
end

Instance Method Details

#label ⇒ Object



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

def label
  user.send(source.name)
end

#scope ⇒ Object



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

def scope
  source.scope
end

#scope_id ⇒ Object



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

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