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
-
#hide_accounts!(mode = true) ⇒ Object
for testing setup.
- #instant_account_activation ⇒ Object
-
#needs_setup? ⇒ true/false
app is not totally set up yet.
-
#simulate_setup_need!(mode = true) ⇒ Object
act as if site is not set up.
Instance Method Details
#hide_accounts!(mode = true) ⇒ Object
for testing setup
26 27 28 29 |
# File 'lib/card/auth/setup.rb', line 26 def hide_accounts! mode=true Card.cache.delete(SETUP_COMPLETED_KEY) if mode @hidden_accounts = mode && user_account_ids end |
#instant_account_activation ⇒ Object
31 32 33 34 35 36 |
# File 'lib/card/auth/setup.rb', line 31 def instant_account_activation simulate_setup_need! yield ensure simulate_setup_need! false end |
#needs_setup? ⇒ true/false
app is not totally set up yet
10 11 12 13 14 15 16 17 |
# File 'lib/card/auth/setup.rb', line 10 def needs_setup? # FIXME: - should not require a cache lookup with every request!! @simulating_setup_need || ( !Card.cache.read(SETUP_COMPLETED_KEY) && !Card.cache.write(SETUP_COMPLETED_KEY, user_account_count.positive?) ) # every deck starts with two accounts: WagnBot and Anonymous end |
#simulate_setup_need!(mode = true) ⇒ Object
act as if site is not set up
21 22 23 |
# File 'lib/card/auth/setup.rb', line 21 def simulate_setup_need! mode=true @simulating_setup_need = mode end |