Module: Brice::History::Tee

Defined in:
lib/brice/history.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


128
129
130
131
132
133
134
135
136
# File 'lib/brice/history.rb', line 128

def self.extended(base)
  class << base
    alias_method :push_without_tee,   :<<
    alias_method :push_m_without_tee, :push

    alias_method :<<,   :push_with_tee
    alias_method :push, :push_m_with_tee
  end
end

Instance Method Details

#push_m_with_tee(*args) ⇒ Object


155
156
157
158
159
160
# File 'lib/brice/history.rb', line 155

def push_m_with_tee(*args)
  _tee_delete(*args)

  tee.concat(args)
  push_m_without_tee(*args)
end

#push_with_tee(arg) ⇒ Object


148
149
150
151
152
153
# File 'lib/brice/history.rb', line 148

def push_with_tee(arg)
  _tee_delete(arg)

  tee << arg
  push_without_tee(arg)
end

#teeObject


138
139
140
# File 'lib/brice/history.rb', line 138

def tee
  @tee ||= []
end

#tee!Object


142
143
144
145
146
# File 'lib/brice/history.rb', line 142

def tee!
  yield tee
ensure
  tee.clear
end