Module: ShadyDB::Finders::ClassMethods

Defined in:
lib/shadydb/finders.rb

Instance Method Summary collapse

Instance Method Details

#exists?(id) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/shadydb/finders.rb', line 21

def exists?(id)
  document = self.new :id => id
  File.exist?(document.path)
end

#find(id) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/shadydb/finders.rb', line 12

def find(id)
  return false unless self.exists?(id)
  
  document = self.new :id => id
  document.send(:restore!)
  document.instance_variable_set('@new_record', false)
  document
end