Class: Build::Files::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/build/files/handle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(monitor, files, &block) ⇒ Handle

Returns a new instance of Handle.



26
27
28
29
30
# File 'lib/build/files/handle.rb', line 26

def initialize(monitor, files, &block)
	@monitor = monitor
	@state = State.new(files)
	@block = block
end

Instance Attribute Details

#monitorObject (readonly)

Returns the value of attribute monitor.



32
33
34
# File 'lib/build/files/handle.rb', line 32

def monitor
  @monitor
end

Instance Method Details

#changed!Object

Inform the handle that it might have been modified.



47
48
49
50
51
52
# File 'lib/build/files/handle.rb', line 47

def changed!
	# If @state.update! did not find any changes, don't invoke the callback:
	if @state.update!
		@block.call(@state)
	end
end

#commit!Object



34
35
36
# File 'lib/build/files/handle.rb', line 34

def commit!
	@state.update!
end

#directoriesObject



38
39
40
# File 'lib/build/files/handle.rb', line 38

def directories
	@state.files.roots
end

#remove!Object



42
43
44
# File 'lib/build/files/handle.rb', line 42

def remove!
	@monitor.delete(self)
end

#to_sObject



54
55
56
# File 'lib/build/files/handle.rb', line 54

def to_s
	"\#<#{self.class} @state=#{@state} @block=#{@block}>"
end