Module: Card::Set::Type::Signup

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod011-card-mod-account/type/signup.rb,
card/tmpsets/set/mod011-card-mod-account/type/signup/views.rb,
card/tmpsets/set/mod010-card-mod-account/type/signup.rb,
card/tmpsets/set/mod010-card-mod-account/type/signup/views.rb

Overview

Set: All “Signup” cards

Defined Under Namespace

Modules: Views

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from AdvancedApi

#attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Card::Set::Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-account/set/type/signup.rb"; end

Instance Method Details

#account_subfieldObject



45
46
47
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 45

def 
  subfield(:account) || add_subfield(:account)
end

#activate_accountedObject



20
21
22
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 20

def activate_accounted
  self.type_id = Card.default_accounted_type_id
end

#approvableObject



55
56
57
58
59
60
61
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 55

def approvable
  if can_approve?
    yield
  else
    abort :failure, "illegal approval" # raise permission denied?
  end
end

#can_approve?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 16

def can_approve?
  Card.new(type_id: Card.default_accounted_type_id).ok? :create
end

#default_account_statusObject



12
13
14
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 12

def 
  can_approve? ? "unverified" : "unapproved"
end

#event: act_as_current_for_integrate_stageObject



40
41
42
43
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 40

event :act_as_current_for_integrate_stage, :integrate, on: :create do
  # needs justification!
  Auth.current_id = id
end

#event: approve_with_verificationObject



28
29
30
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 28

event :approve_with_verification, :validate, on: :update, trigger: :required do
  approvable { request_verification }
end

#event: approve_without_verificationObject



32
33
34
35
36
37
38
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 32

event :approve_without_verification, :validate, on: :update, trigger: :required do
  # TODO: if validated here, add trigger and activate in storage phase
  approvable do
    activate_accounted
    .
  end
end

#event: auto_approve_with_verificationObject



24
25
26
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 24

event :auto_approve_with_verification, :validate, on: :create, when: :can_approve? do
  request_verification
end

#request_verificationObject



49
50
51
52
53
# File 'card/tmpsets/set/mod011-card-mod-account/type/signup.rb', line 49

def request_verification
  acct = 
  acct.add_subfield :status, content: "unverified"
  acct.trigger_event! :send_verification_email
end