class SwitchUser::DataSource
Attributes
identifier[R]
loader[R]
name[R]
scope[R]
Public Class Methods
new(loader, scope, identifier, name)
click to toggle source
# File lib/switch_user/data_source.rb, line 23 def initialize(loader, scope, identifier, name) @loader = loader @scope = scope @identifier = identifier @name = name end
Public Instance Methods
all()
click to toggle source
# File lib/switch_user/data_source.rb, line 30 def all loader.call.map { |user| Record.new(user, self) } end
find_scope_id(scope_id)
click to toggle source
# File lib/switch_user/data_source.rb, line 34 def find_scope_id(scope_id) scope_regexp = /\A#{scope}_/ return unless scope_id =~ scope_regexp user = loader.call.where(identifier => scope_id.sub(scope_regexp, '')).first Record.new(user, self) end