summaryrefslogtreecommitdiff
path: root/example/models/log.rb
blob: 9e700a82dda00a69dc7078fd3d77a118206f6f9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'yaml'

class Log

  def self.current
    @current ||= Log.new
  end

  def self.log(*args)
    self.current.log(*args)
  end

  def self.clear
    @current = nil
  end

  attr_accessor :actions

  def initialize
    @actions = []
  end

  def log(action, params)
    @actions << {action => params.dup}
  end

  def pretty
    @actions.to_yaml
  end

end