Module: Jaysus::Local

Defined in:
lib/jaysus/local.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
# File 'lib/jaysus/local.rb', line 11

def self.included(base)
  base.extend(ClassMethods)
end

.store_dirObject



3
4
5
# File 'lib/jaysus/local.rb', line 3

def self.store_dir
  @store_dir ||= Pathname.new('.')
end

.store_dir=(dir) ⇒ Object



7
8
9
# File 'lib/jaysus/local.rb', line 7

def self.store_dir=(dir)
  @store_dir = Pathname.new(dir)
end

Instance Method Details

#destroyObject



15
16
17
18
19
20
# File 'lib/jaysus/local.rb', line 15

def destroy
  super do
    store_file.delete
    self
  end
end

#saveObject



22
23
24
25
26
27
28
29
# File 'lib/jaysus/local.rb', line 22

def save
  super do
    store_file.open('w') do |file|
      file.write(self.to_json)
    end
    self
  end
end