Module: Card::Set::All::History::Export::JsonFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb

Instance Method Summary collapse

Instance Method Details

#act_hash(act) ⇒ Object



31
32
33
34
35
36
37
38
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb', line 31

def act_hash act
  {
    act_id: act.id,
    actor_id: act.actor_id,
    acted_at: act.acted_at,
    act_card_id: act.card_id
  }
end

#action_hash(action) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb', line 40

def action_hash action
  {
    action_id: action.id,
    card_id: action.card_id,
    action_type: action.action_type,
    comment: action.comment,
    changes: changes_hash(action.card_changes)
  }
end

#action_hash_list(actions) ⇒ Object



25
26
27
28
29
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb', line 25

def action_hash_list actions
  actions.map do |action|
    act_hash(action.act).merge action_hash(action)
  end
end

#atomObject



9
10
11
12
13
14
15
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb', line 9

def atom
  super.tap do |atom|
    %i[history actions].each do |view|
      atom[view] = render(view) if voo.explicit_show?(view)
    end
  end
end

#changes_hash(changes) ⇒ Object



50
51
52
53
54
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb', line 50

def changes_hash changes
  changes.each_with_object({}) do |change, hash|
    hash[change.field] = change.value
  end
end

#view: actionsObject



21
22
23
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb', line 21

view :actions do
  card.real? ? action_hash_list(card.actions) : []
end

#view: historyObject



17
18
19
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/export.rb', line 17

view :history do
  card.real? ? action_hash_list(card.history_actions) : []
end