Module: Card::Set::Abstract::AccountHolder
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb
Overview
Set: Abstract (AccountHolder)
Defined Under Namespace
Modules: HtmlFormat
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
Methods included from I18nScope
#mod_name, #scope
Methods included from Registrar
#extended, #finalize_load, #process_base_modules, #register_set
Methods included from Helpers
#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name
#assign_type, #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
#include_set, #include_set_formats
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
#event
Class Method Details
.source_location ⇒ Object
7
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 7
def self.source_location; "/Users/ethan/dev/decko/gem/mod/account/set/abstract/account_holder.rb"; end
|
Instance Method Details
14
15
16
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 14
def account
fetch :account, new: {}
end
|
#account? ⇒ Boolean
18
19
20
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 18
def account?
account.real?
end
|
#account_manager? ⇒ Boolean
78
79
80
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 78
def account_manager?
own_account? || parties.member?(HelpDeskID)
end
|
#admin? ⇒ Boolean
70
71
72
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 70
def admin?
role? AdministratorID
end
|
#all_enabled_roles ⇒ Object
46
47
48
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 46
def all_enabled_roles
@all_enabled_roles ||= (id == AnonymousID ? [] : enabled_role_ids)
end
|
#all_roles ⇒ Object
50
51
52
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 50
def all_roles
@all_roles ||= (id == AnonymousID ? [] : fetch_roles)
end
|
#among?(ok_ids) ⇒ Boolean
38
39
40
41
42
43
44
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 38
def among? ok_ids
ok_ids.any? do |ok_id|
ok_id == AnyoneID ||
parties.member?(ok_id)
end
end
|
#clear_roles ⇒ Object
62
63
64
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 62
def clear_roles
@parties = @all_roles = @all_enabled_roles = @read_rules = nil
end
|
#current_account? ⇒ Boolean
30
31
32
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 30
def current_account?
id && Auth.current_id == id
end
|
#default_account_status ⇒ Object
26
27
28
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 26
def default_account_status
"active"
end
|
#event: validate_account_holder_name_change ⇒ Object
8
9
10
11
12
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 8
event :validate_account_holder_name_change, :validate, on: :update, changed: :name do
return unless account? && !Card::Auth.as_card.account_manager?
errors.add :name, "cannot rename Account Holder"
end
|
#ok_to_update? ⇒ Boolean
66
67
68
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 66
def ok_to_update?
(own_account? && !type_id_changed?) || super
end
|
#own_account? ⇒ Boolean
22
23
24
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 22
def own_account?
key == Auth.as_card.key
end
|
34
35
36
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 34
def parties
@parties ||= (all_enabled_roles << id).flatten.reject(&:blank?)
end
|
#read_rules ⇒ Object
54
55
56
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 54
def read_rules
@read_rules ||= fetch_read_rules
end
|
#read_rules_hash ⇒ Object
58
59
60
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 58
def read_rules_hash
@read_rules_hash ||= read_rules.each_with_object({}) { |id, h| h[id] = true }
end
|
#role?(role_mark) ⇒ Boolean
74
75
76
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/abstract/account_holder.rb', line 74
def role? role_mark
all_enabled_roles.include? role_mark.card_id
end
|