Module: Card::Auth::Setup

Included in:
Card::Auth
Defined in:
lib/card/auth/setup.rb

Overview

singleton methods for managing setup state

Constant Summary collapse

NEEDS_SETUP =
"NEEDS_SETUP".freeze

Instance Method Summary collapse

Instance Method Details

#instant_account_activationObject



24
25
26
27
28
29
# File 'lib/card/auth/setup.rb', line 24

def 
  simulate_needs_setup!
  yield
ensure
  simulate_needs_setup! false
end

#needs_setup?true/false

app is not totally set up yet

Returns:

  • (true/false)


9
10
11
12
13
14
15
# File 'lib/card/auth/setup.rb', line 9

def needs_setup?
  if @needs_setup == false || Card.cache.read(NEEDS_SETUP)&.to_s == "false"
    @needs_setup = false
  else
    needs_setup_if_no_accounts
  end
end

#simulate_setup!(mode = true) ⇒ Object

for testing setup



18
19
20
21
22
# File 'lib/card/auth/setup.rb', line 18

def simulate_setup! mode=true
  Card.cache.delete NEEDS_SETUP
  @needs_setup = nil
  @hidden_accounts = mode ?  : nil
end