Module: DuodealerApp::SessionStorage::AccountStorageStrategy

Defined in:
lib/duodealer_app/session/storage_strategies/account_storage_strategy.rb

Instance Method Summary collapse

Instance Method Details

#retrieve(id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/duodealer_app/session/storage_strategies/account_storage_strategy.rb', line 13

def retrieve(id)
  return unless id
  if  = self.find_by(id: id)
    DuodealerAPI::Session.new(
      domain: .duodealer_domain,
      token: .duodealer_token,
      api_version: .api_version
    )
  end
end

#store(auth_session, *args) ⇒ Object



6
7
8
9
10
11
# File 'lib/duodealer_app/session/storage_strategies/account_storage_strategy.rb', line 6

def store(auth_session, *args)
   = find_or_initialize_by(duodealer_domain: auth_session.domain)
  .duodealer_token = auth_session.token
  .save!
  .id
end