Module: Card::Set::All::Notify::BaseViews::Format

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod017-follow/all/notify/base_views.rb

Instance Method Summary collapse

Instance Method Details

#active_notice(key) ⇒ Object



84
85
86
87
88
89
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 84

def active_notice key
  @active_notice ||= inherit :active_notice
  return unless @active_notice

  @active_notice[key]
end

#edit_info_for(field, action) ⇒ Object



97
98
99
100
101
102
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 97

def edit_info_for field, action
  return nil unless (value = action.value field)

  value = action.previous_value if action.action_type == :delete
  wrap_list_item "  #{notification_action_label action} #{field}: #{value}"
end

#follow_option_cardObject



78
79
80
81
82
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 78

def follow_option_card
  return unless (option_name = active_notice(:follow_option))

  Card.fetch option_name
end

#followed_set_cardObject



74
75
76
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 74

def followed_set_card
  (set_name = active_notice(:followed_set)) && Card.fetch(set_name)
end

#live_follow_rule_nameObject



91
92
93
94
95
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 91

def live_follow_rule_name
  return unless (set_card = followed_set_card) && (follower = active_notice(:follower))

  set_card.follow_rule_name follower
end

#name_before_action(action) ⇒ Object



70
71
72
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 70

def name_before_action action
  (action.value(:name) && action.previous_value(:name)) || card.name
end

#notification_act(act = nil) ⇒ Object



130
131
132
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 130

def notification_act act=nil
  @notification_act ||= act || card.acts.last
end

#notification_action(action_id) ⇒ Object



134
135
136
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 134

def notification_action action_id
  action_id ? Action.fetch(action_id) : card.last_action
end

#notification_action_label(action) ⇒ Object



104
105
106
107
108
109
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 104

def notification_action_label action
  case action.action_type
  when :update then "new"
  when :delete then "deleted"
  end
end

#relevant_fields(action) ⇒ Object



62
63
64
65
66
67
68
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 62

def relevant_fields action
  case action.action_type
  when :create then %i[cardtype content]
  when :update then %i[name cardtype content]
  when :delete then %i[content]
  end
end

#wrap_list(list) ⇒ Object



118
119
120
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 118

def wrap_list list
  "\n#{list}\n"
end

#wrap_list_item(item) ⇒ Object



122
123
124
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 122

def wrap_list_item item
  "#{item}\n"
end

#wrap_subedit_itemObject



126
127
128
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 126

def wrap_subedit_item
  "\n#{yield}\n"
end

#wrap_subeditsObject



111
112
113
114
115
116
# File 'tmpsets/set/mod017-follow/all/notify/base_views.rb', line 111

def wrap_subedits
  subedits = yield.compact.join
  return "" if subedits.blank?

  "\nThis update included the following changes:\n#{wrap_list subedits}"
end