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

SETUP_COMPLETED_KEY =
"SETUP_COMPLETED".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_setup_need!
  yield
ensure
  simulate_setup_need! false
end

#needs_setup?true/false

app is not totally set up yet

Returns:

  • (true/false)


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

def needs_setup?
  @simulating_setup_need || (
    !Card.cache.read(SETUP_COMPLETED_KEY) &&
    !Card.cache.write(SETUP_COMPLETED_KEY,  > 2)
  )
  # every deck starts with two accounts: WagnBot and Anonymous
end

#simulate_setup_need!(mode = true) ⇒ Object

act as if site is not set up

Parameters:

  • mode (true/false) (defaults to: true)

    simulate setup need if true



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

def simulate_setup_need! mode=true
  @simulating_setup_need = mode
end