Class: Noid::Rails::Minter::File
- Defined in:
- lib/noid/rails/minter/file.rb
Overview
A file based minter. This is a simple case.
Instance Attribute Summary collapse
-
#statefile ⇒ Object
readonly
Returns the value of attribute statefile.
Instance Method Summary collapse
- #default_statefile ⇒ Object
-
#initialize(template = default_template, statefile = default_statefile) ⇒ File
constructor
A new instance of File.
- #read ⇒ Object
- #write!(minter) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(template = default_template, statefile = default_statefile) ⇒ File
Returns a new instance of File.
12 13 14 15 |
# File 'lib/noid/rails/minter/file.rb', line 12 def initialize(template = default_template, statefile = default_statefile) @statefile = statefile super(template) end |
Instance Attribute Details
#statefile ⇒ Object (readonly)
Returns the value of attribute statefile.
10 11 12 |
# File 'lib/noid/rails/minter/file.rb', line 10 def statefile @statefile end |
Instance Method Details
#default_statefile ⇒ Object
17 18 19 |
# File 'lib/noid/rails/minter/file.rb', line 17 def default_statefile Noid::Rails.config.statefile end |
#read ⇒ Object
21 22 23 24 25 |
# File 'lib/noid/rails/minter/file.rb', line 21 def read with_file do |f| state_for(f) end end |
#write!(minter) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/noid/rails/minter/file.rb', line 27 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 |