Module: Card::Set::All::Account

Extended by:
Card::Set
Defined in:
tmpsets/set/mod007-05_standard/all/account.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Card::Set

abstract_set?, all_set?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_active_job, define_event_method, define_event_perform_later_method, define_on_format, ensure_set, event, extended, format, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, view, write_tmp_file

Instance Method Details

#accountObject



9
10
11
# File 'tmpsets/set/mod007-05_standard/all/account.rb', line 9

def 
  fetch :trait=>:account
end

#accountable?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'tmpsets/set/mod007-05_standard/all/account.rb', line 13

def accountable?
  Card.toggle( rule :accountable )
end

#all_rolesObject



48
49
50
51
52
53
54
55
56
57
58
# File 'tmpsets/set/mod007-05_standard/all/account.rb', line 48

def all_roles
  @all_roles ||= 
    if id == Card::AnonymousID
      []
    else
      Auth.as_bot do
        role_trait = fetch :trait=>:roles
        [ Card::AnyoneSignedInID ] + ( role_trait ? role_trait.item_ids : [] )
      end
    end
end

#among?(ok_ids) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'tmpsets/set/mod007-05_standard/all/account.rb', line 21

def among? ok_ids
  ok_ids.each do |ok_id|
    return true if parties.member? ok_id
  end
  ok_ids.member? Card::AnyoneID
end

#is_own_account?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'tmpsets/set/mod007-05_standard/all/account.rb', line 28

def is_own_account?
  # card is +*account card of signed_in user.
  cardname.part_names[0].key == Auth.as_card.key and
  cardname.part_names[1].key == Card[:account].key
end

#partiesObject



17
18
19
# File 'tmpsets/set/mod007-05_standard/all/account.rb', line 17

def parties
  @parties ||= (all_roles << self.id).flatten.reject(&:blank?)
end

#read_rulesObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'tmpsets/set/mod007-05_standard/all/account.rb', line 34

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