Class: Gitolite::DirtyProxy

Inherits:
BasicObject
Defined in:
lib/gitolite/dirty_proxy.rb

Overview

Very simple proxy object for checking if the proxied object was modified since the last clean_up! method called. It works correctly only for objects with proper hash method!

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ DirtyProxy

Returns a new instance of DirtyProxy.


9
10
11
12
# File 'lib/gitolite/dirty_proxy.rb', line 9

def initialize(target)
  @target = target
  clean_up!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object


14
15
16
# File 'lib/gitolite/dirty_proxy.rb', line 14

def method_missing(method, *args, &block)
  @target.send(method, *args, &block)
end

Instance Method Details

#clean_up!Object


26
27
28
# File 'lib/gitolite/dirty_proxy.rb', line 26

def clean_up!
  @clean_hash = @target.hash
end

#dirty?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/gitolite/dirty_proxy.rb', line 22

def dirty?
  @clean_hash != @target.hash
end

#respond_to?(symbol, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

18
19
20
# File 'lib/gitolite/dirty_proxy.rb', line 18

def respond_to?(symbol, include_private=false)
  super || [:dirty?, :clean_up!].include?(symbol.to_sym)
end