Module: Card::Set::Right::Account

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod025-card-mod-follow/right/account.rb,
card/tmpsets/set/mod011-card-mod-account/right/account.rb,
card/tmpsets/set/mod011-card-mod-account/right/account/views.rb,
card/tmpsets/set/mod011-card-mod-account/right/account/events.rb,
card/tmpsets/set/mod026-card-mod-follow/right/account.rb,
card/tmpsets/set/mod010-card-mod-account/right/account.rb,
card/tmpsets/set/mod019-card-mod-api_key/right/account.rb,
card/tmpsets/set/mod010-card-mod-account/right/account/views.rb,
card/tmpsets/set/mod010-card-mod-account/right/account/events.rb

Overview

Set: All “+Account” cards

Defined Under Namespace

Modules: Events, HtmlFormat, 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

#num_set_parts, #pattern_code, #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 Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



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

def method_missing method, *args
  super unless args.empty? && (matches = method.match(/^(?<status>.*)\?$/))

  status == matches[:status]
end

Class Method Details

.source_locationObject



7
# File 'card/tmpsets/set/mod025-card-mod-follow/right/account.rb', line 7

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

Instance Method Details

#accountedObject



18
19
20
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 18

def accounted
  left
end

#accounted_idObject



22
23
24
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 22

def accounted_id
  left_id
end

#changes_visible?(act) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 37

def changes_visible? act
  act.actions_affecting(act.card).each do |action|
    return true if action.card.ok? :read
  end
  false
end

#notify_of_act(act) ⇒ Object



16
17
18
19
20
21
22
# File 'card/tmpsets/set/mod025-card-mod-follow/right/account.rb', line 16

def notify_of_act act
  Auth.as(left.id) do
    Card[:follower_notification_email].deliver(
      act.card, { to: email }, auth: left, active_notice: yield
    )
  end
end

#ok_to_readObject



26
27
28
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 26

def ok_to_read
  own_account? ? true : super
end

#ok_to_updateObject

allow account owner to update account field content



31
32
33
34
35
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 31

def ok_to_update
  return true if own_account? && !name_changed? && !type_id_changed?

  super
end

#respond_to_missing?(method, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 63

def respond_to_missing? method, _include_private=false
  method.match?(/\?/) ? true : super
end

#send_account_email(email_template) ⇒ Object



44
45
46
47
48
49
50
51
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 44

def  email_template
  ecard = Card[email_template]
  unless ecard&.type_id == EmailTemplateID
    raise Card::Error, "invalid email template: #{email_template}"
  end

  ecard.deliver self, to: email
end

#send_change_notice(act, followed_set, follow_option) ⇒ Object



8
9
10
11
12
13
14
# File 'card/tmpsets/set/mod025-card-mod-follow/right/account.rb', line 8

def send_change_notice act, followed_set, follow_option
  return unless email.present? && changes_visible?(act)

  notify_of_act act do
    { follower: left.name, followed_set: followed_set, follow_option: follow_option }
  end
end

#validate_api_key!(api_key) ⇒ Object



53
54
55
# File 'card/tmpsets/set/mod011-card-mod-account/right/account.rb', line 53

def validate_api_key! api_key
  api_key_card.validate! api_key
end