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

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod028-follow/right/account.rb,
platypus/tmp/set/gem-defaults/mod014-account/right/account.rb,
platypus/tmp/set/gem-defaults/mod021-api_key/right/account.rb,
platypus/tmp/set/gem-defaults/mod014-account/right/account/views.rb,
platypus/tmp/set/gem-defaults/mod014-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

Methods included from I18nScope

#mod_name, #scope

Methods included from Card::Set::Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #modules, #pattern_code, #set_name_parts, #shortname, #underscored_name

Methods included from AdvancedApi

#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

Methods included from Inheritance

#include_set, #include_set_formats

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



54
55
56
57
58
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 54

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

  status == matches[:status]
end

Class Method Details

.source_locationObject



7
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/account.rb', line 7

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

Instance Method Details

#accountedObject



21
22
23
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 21

def accounted
  left
end

#accounted_idObject



25
26
27
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 25

def accounted_id
  left_id
end

#changes_visible?(act) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 38

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 'platypus/tmp/set/gem-defaults/mod028-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_read?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 29

def ok_to_read?
  own_account? || super
end

#ok_to_update?Boolean

allow account owner to update account field content

Returns:

  • (Boolean)


34
35
36
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 34

def ok_to_update?
  (own_account? && !name_changed? && !type_id_changed?) || super
end

#own_account?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 17

def own_account?
  accounted&.try :own_account?
end

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

Returns:

  • (Boolean)


60
61
62
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 60

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

#send_account_email(email_template) ⇒ Object



45
46
47
48
49
50
51
52
# File 'platypus/tmp/set/gem-defaults/mod014-account/right/account.rb', line 45

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 'platypus/tmp/set/gem-defaults/mod028-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