Module: Tyrion::Persistence::ClassMethods

Defined in:
lib/tyrion/persistence.rb

Instance Method Summary collapse

Instance Method Details

#create(attributes = {}) ⇒ Object



6
7
8
9
10
# File 'lib/tyrion/persistence.rb', line 6

def create attributes = {}
  new.tap do |n|
    attributes.each_pair{ |k, v| n.send(:write_attribute, k.to_s, v) }
  end
end

#create!(attributes = {}) ⇒ Object



12
13
14
# File 'lib/tyrion/persistence.rb', line 12

def create! attributes = {}
  create(attributes).tap{ |doc| doc.save }
end

#delete(attributes = {}) ⇒ Object



20
21
22
# File 'lib/tyrion/persistence.rb', line 20

def delete attributes = {}
  where(attributes).each(&:delete)
end

#delete_allObject



16
17
18
# File 'lib/tyrion/persistence.rb', line 16

def delete_all
  storage[klass_name].clear
end