Class: Gluer::File

Inherits:
Object
  • Object
show all
Defined in:
lib/gluer/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ File

Returns a new instance of File.



8
9
10
# File 'lib/gluer/file.rb', line 8

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/gluer/file.rb', line 6

def path
  @path
end

Instance Method Details

#add_registration(registration) ⇒ Object



20
21
22
23
# File 'lib/gluer/file.rb', line 20

def add_registration(registration)
  new_registration_pool.add(registration)
  touch
end

#reloadObject



30
31
32
33
34
35
36
37
38
# File 'lib/gluer/file.rb', line 30

def reload
  load_from_source
  if touched?
    registration_pool.rollback
    new_registration_pool.commit
    registration_pool.replace(new_registration_pool)
    new_registration_pool.clear
  end
end

#touchObject



12
13
14
# File 'lib/gluer/file.rb', line 12

def touch
  @touched = true
end

#touched?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/gluer/file.rb', line 16

def touched?
  !!@touched
end

#unloadObject



25
26
27
28
# File 'lib/gluer/file.rb', line 25

def unload
  registration_pool.rollback
  registration_pool.clear
end