Module: MmAdapter::ClassMethods

Defined in:
lib/models/mm_adapter.rb

Instance Method Summary collapse

Instance Method Details

#allObject



8
9
10
11
# File 'lib/models/mm_adapter.rb', line 8

def all
  result = MmUser.all(:order => 'created_at desc')
  result.collect {|instance| self.new instance}
end

#delete(pk) ⇒ Object



34
35
36
37
38
39
# File 'lib/models/mm_adapter.rb', line 34

def delete(pk)
  user = MmUser.first(:id => pk)
  #returns nil on success. Is this correct? Will it return something else on failure?
  user.destroy
  user.destroyed?
end

#get(hash) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/models/mm_adapter.rb', line 13

def get(hash)
  if user = MmUser.first(hash)
    self.new user
  else
    nil
  end
end

#set(attributes) ⇒ Object



21
22
23
24
25
26
# File 'lib/models/mm_adapter.rb', line 21

def set(attributes)
  #puts attributes.inspect
  user = MmUser.new attributes
  user.id = nil unless user.save
  self.new user
end

#set!(attributes) ⇒ Object



28
29
30
31
32
# File 'lib/models/mm_adapter.rb', line 28

def set!(attributes)
  user = MmUser.new attributes
  user.save(:validate => false)
  self.new user
end