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.



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

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

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



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

def source
  @source
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#labelObject



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

def label
  user.send(source.name)
end

#scopeObject



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

def scope
  source.scope
end

#scope_idObject



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

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