Class: Milkshake::Linker

Inherits:
Object
  • Object
show all
Defined in:
lib/milkshake/linker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, validator, cache) ⇒ Linker

Returns a new instance of Linker.



9
10
11
12
13
# File 'lib/milkshake/linker.rb', line 9

def initialize(environment, validator, cache)
  @environment = environment
  @validator   = validator
  @cache       = cache
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



7
8
9
# File 'lib/milkshake/linker.rb', line 7

def cache
  @cache
end

#current_snapshotObject (readonly)

Returns the value of attribute current_snapshot.



7
8
9
# File 'lib/milkshake/linker.rb', line 7

def current_snapshot
  @current_snapshot
end

#environmentObject (readonly)

Returns the value of attribute environment.



7
8
9
# File 'lib/milkshake/linker.rb', line 7

def environment
  @environment
end

#validatorObject (readonly)

Returns the value of attribute validator.



7
8
9
# File 'lib/milkshake/linker.rb', line 7

def validator
  @validator
end

Instance Method Details

#link!Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/milkshake/linker.rb', line 15

def link!
  link_only_once do
    if validator.relink?
      @current_snapshot = Snapshots.dump
      
      run_migrations!
      
      validator.persist!
      cache.persist!
    end
  end
end