Sha256: 2c0d3795b38ea7439e00105ae0bdbcea7d26a1e1c55c0ad6f67d7009c2ea243b

Contents?: true

Size: 981 Bytes

Versions: 4

Compression:

Stored size: 981 Bytes

Contents

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

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

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

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

  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

  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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
card-mod-history-0.18.1 set/all/history/export.rb
card-mod-history-0.18.0 set/all/history/export.rb
card-mod-history-0.17.0 set/all/history/export.rb
card-mod-history-0.16.0 set/all/history/export.rb