Module: Card::Set::All::Account
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod017-account/all/account.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary
Constants included from Format
Instance Method Summary collapse
- #account ⇒ Object
- #accountable? ⇒ Boolean
- #all_roles ⇒ Object
- #among?(ok_ids) ⇒ Boolean
- #fetch_roles ⇒ Object
- #own_account? ⇒ Boolean
- #parties ⇒ Object
- #read_rules ⇒ Object
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#abstract_set?, #all_set?, #num_set_parts, #shortname
Methods included from Card::Set::AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer
Methods included from Event
Instance Method Details
#account ⇒ Object
10 11 12 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 10 def account fetch trait: :account end |
#accountable? ⇒ Boolean
14 15 16 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 14 def accountable? Card.toggle(rule(:accountable)) end |
#all_roles ⇒ Object
49 50 51 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 49 def all_roles @all_roles ||= (id == Card::AnonymousID ? [] : fetch_roles) end |
#among?(ok_ids) ⇒ Boolean
22 23 24 25 26 27 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 22 def among? ok_ids ok_ids.each do |ok_id| return true if parties.member? ok_id end ok_ids.member? Card::AnyoneID end |
#fetch_roles ⇒ Object
53 54 55 56 57 58 59 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 53 def fetch_roles Auth.as_bot do role_trait = fetch trait: :roles next [Card::AnyoneSignedInID] unless role_trait [Card::AnyoneSignedInID] + role_trait.item_ids end end |
#own_account? ⇒ Boolean
29 30 31 32 33 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 29 def own_account? # card is +*account card of signed_in user. cardname.part_names[0].key == Auth.as_card.key && cardname.part_names[1].key == Card[:account].key end |
#parties ⇒ Object
18 19 20 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 18 def parties @parties ||= (all_roles << id).flatten.reject(&:blank?) end |
#read_rules ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'tmpsets/set/mod017-account/all/account.rb', line 35 def read_rules @read_rules ||= begin rule_ids = [] unless id == Card::WagnBotID # always_ok, so not needed ([Card::AnyoneID] + parties).each do |party_id| if (rule_ids_for_party = self.class.read_rule_cache[party_id]) rule_ids += rule_ids_for_party end end end rule_ids end end |