Sha256: d6c564daf1a9115b7aedf9215c8bfa7fc9084c7c04b045ebfdd4a26dddeb2113
Contents?: true
Size: 807 Bytes
Versions: 2
Compression:
Stored size: 807 Bytes
Contents
module Jaysus module Local def self.store_dir @store_dir ||= Pathname.new('.') end def self.store_dir=(dir) @store_dir = Pathname.new(dir) end def self.included(base) base.extend(ClassMethods) end def destroy super do store_file.delete self end end def save super do store_file.open('w') do |file| file.write(self.to_json) end self end end module ClassMethods def all records = [] Dir[store_file_dir.join('*')].each do |id| records << find(id) end records end def find(id) super do store_file_dir.join("#{id}").read end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jaysus-0.1.1 | lib/jaysus/local.rb |
jaysus-0.1.0 | lib/jaysus/local.rb |