Module: ActiveFiles::Record

Defined in:
lib/active_files/record.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/active_files/record.rb', line 5

def self.included(base)
  base.module_eval do
    extend ActiveFiles::Record::ClassMethods
  end
end

Instance Method Details

#deleteObject



137
138
139
# File 'lib/active_files/record.rb', line 137

def delete
  File.delete(filename)
end

#file_idObject



141
142
143
# File 'lib/active_files/record.rb', line 141

def file_id
  @file_id
end

#saveObject



126
127
128
129
130
131
132
133
134
135
# File 'lib/active_files/record.rb', line 126

def save
  raise ActiveFiles::NoFileId if self.file_id.nil?
  File.open(filename, 'w') do |file|
    file.puts self.to_activefile
  end
  true
rescue Errno::ENOENT
  self.class.create_file_store
  self.save
end