Module: Card::Set::All::Account
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod014-account/all/account.rb
Overview
Defined Under Namespace
Modules: ClassMethods
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/all/account.rb', line 7
def self.source_location; "/Users/ethan/dev/decko/gem/mod/account/set/all/account.rb"; end
|
Instance Method Details
14
15
16
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 14
def account
fetch :account
end
|
#all_enabled_roles ⇒ Object
def with_clear_roles
a = @parties
b = @all_roles
c = @all_active_roles
d = @read_rules
yield
ensure
@parties = a
@all_roles = b
@all_active_roles = c
@read_rules = d
end
71
72
73
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 71
def all_enabled_roles
@all_active_roles ||= (id == AnonymousID ? [] : enabled_role_ids)
end
|
#all_roles ⇒ Object
75
76
77
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 75
def all_roles
@all_roles ||= (id == AnonymousID ? [] : fetch_roles)
end
|
#among?(ok_ids) ⇒ Boolean
22
23
24
25
26
27
28
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 22
def among? ok_ids
ok_ids.any? do |ok_id|
ok_id == AnyoneID ||
parties.member?(ok_id)
end
end
|
#clear_roles ⇒ Object
54
55
56
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 54
def clear_roles
@parties = @all_roles = @all_active_roles = @read_rules = nil
end
|
#enabled_role_ids ⇒ Object
79
80
81
82
83
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 79
def enabled_role_ids
with_enabled_roles do |enabled|
enabled.virtual? ? enabled.item_ids : fetch_roles
end
end
|
#enabled_roles_card ⇒ Object
91
92
93
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 91
def enabled_roles_card
fetch :enabled_roles, eager_cache: true, new: { type_id: SessionID }
end
|
#event: generate_token ⇒ Object
103
104
105
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 103
event :generate_token do
Digest::SHA1.hexdigest "--#{Time.zone.now.to_f}--#{rand 10}--"
end
|
#event: set_stamper ⇒ Object
107
108
109
110
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 107
event :set_stamper, :prepare_to_validate do
self.updater_id = Auth.current_id
self.creator_id = updater_id if new_card?
end
|
#fetch_read_rules ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 44
def fetch_read_rules
return [] if id == WagnBotID
([AnyoneID] + parties).each_with_object([]) do |party_id, rule_ids|
next unless (cache = Card::Rule.read_rule_cache[party_id])
rule_ids.concat cache
end
end
|
#fetch_roles ⇒ Object
95
96
97
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 95
def fetch_roles
[AnyoneSignedInID] + role_ids_from_role_member_cards
end
|
#own_account? ⇒ Boolean
30
31
32
33
34
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 30
def own_account?
name.part_names[0].key == Auth.as_card.key &&
name.part_names[1].key == Card[:account].key
end
|
18
19
20
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 18
def parties
@parties ||= (all_enabled_roles << id).flatten.reject(&:blank?)
end
|
#read_rules ⇒ Object
36
37
38
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 36
def read_rules
@read_rules ||= fetch_read_rules
end
|
#read_rules_hash ⇒ Object
40
41
42
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 40
def read_rules_hash
@read_rules_hash ||= read_rules.each_with_object({}) { |id, h| h[id] = true }
end
|
#role_ids_from_role_member_cards ⇒ Object
99
100
101
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 99
def role_ids_from_role_member_cards
Self::Role.role_ids id
end
|
#with_enabled_roles ⇒ Object
85
86
87
88
89
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/all/account.rb', line 85
def with_enabled_roles
Auth.as_bot do
Card::Codename.exists?(:enabled_roles) ? yield(enabled_roles_card) : fetch_roles
end
end
|