Class: Build::Files::Monitor::Handle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Handle.



12
13
14
15
16
# File 'lib/build/files/monitor/handle.rb', line 12

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.



18
19
20
# File 'lib/build/files/monitor/handle.rb', line 18

def monitor
  @monitor
end

Instance Method Details

#changed!Object

Inform the handle that it might have been modified.



33
34
35
36
37
38
# File 'lib/build/files/monitor/handle.rb', line 33

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



20
21
22
# File 'lib/build/files/monitor/handle.rb', line 20

def commit!
	@state.update!
end

#directoriesObject



24
25
26
# File 'lib/build/files/monitor/handle.rb', line 24

def directories
	@state.files.roots
end

#remove!Object



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

def remove!
	@monitor.delete(self)
end

#to_sObject



40
41
42
# File 'lib/build/files/monitor/handle.rb', line 40

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