Class: ActiveFedora::Noid::Minter::File

Inherits:
Base
  • Object
show all
Defined in:
lib/active_fedora/noid/minter/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#mint

Constructor Details

#initialize(template = default_template, statefile = default_statefile) ⇒ File

Returns a new instance of File.



10
11
12
13
# File 'lib/active_fedora/noid/minter/file.rb', line 10

def initialize(template = default_template, statefile = default_statefile)
  @statefile = statefile
  super(template)
end

Instance Attribute Details

#statefileObject (readonly)

Returns the value of attribute statefile.



8
9
10
# File 'lib/active_fedora/noid/minter/file.rb', line 8

def statefile
  @statefile
end

Instance Method Details

#default_statefileObject



15
16
17
# File 'lib/active_fedora/noid/minter/file.rb', line 15

def default_statefile
  ActiveFedora::Noid.config.statefile
end

#readObject



19
20
21
22
23
# File 'lib/active_fedora/noid/minter/file.rb', line 19

def read
  with_file do |f|
    state_for(f)
  end
end

#write!(minter) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/active_fedora/noid/minter/file.rb', line 25

def write!(minter)
  with_file do |f|
    # Wipe prior contents so the new state can be written from the beginning of the file
    f.truncate(0)
    f.write(Marshal.dump(minter.dump))
  end
end