class Hello::RequestManager::Stateful::Finder
Public Class Methods
new(manager)
click to toggle source
# File lib/hello/request_manager/stateful/finder.rb, line 5 def initialize(manager) @manager = manager end
Public Instance Methods
current_accesses()
click to toggle source
# File lib/hello/request_manager/stateful/finder.rb, line 9 def current_accesses @models || models end
models()
click to toggle source
# File lib/hello/request_manager/stateful/finder.rb, line 13 def models gather_wanted_strings gather_wanted_models gather_valid_strings ensure_consistency_accross_models_and_session @models end
Private Instance Methods
ensure_consistency_accross_models_and_session()
click to toggle source
# File lib/hello/request_manager/stateful/finder.rb, line 49 def ensure_consistency_accross_models_and_session if @wanted_strings != @valid_strings @manager.session_tokens = @valid_strings @models = @models.select { |a| @valid_strings.include?(a.token) } end end
gather_valid_strings()
click to toggle source
# File lib/hello/request_manager/stateful/finder.rb, line 45 def gather_valid_strings @valid_strings = @models.map(&:active_token_or_destroy).map(&:presence).compact end
gather_wanted_models()
click to toggle source
# File lib/hello/request_manager/stateful/finder.rb, line 29 def gather_wanted_models strings = @wanted_strings # a small attempt to avoid a database call unless needed case strings.size when 0 then return @models = [] when 1 then strings = strings.first end # TODO: # optimize this process since each string starts with the user_id, # check StatelessRequestManager for example @models = ::Access.where(token: strings) end
gather_wanted_strings()
click to toggle source
# File lib/hello/request_manager/stateful/finder.rb, line 25 def gather_wanted_strings @wanted_strings = @manager.session_tokens end