Module: ArAdapter::ClassMethods

Defined in:
lib/models/ar_adapter.rb

Instance Method Summary collapse

Instance Method Details

#allObject

pass all args to this



9
10
11
12
# File 'lib/models/ar_adapter.rb', line 9

def all
  result = ArUser.all(:order => ["created_at DESC"])
  result.collect {|instance| self.new instance}
end

#delete(pk) ⇒ Object



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

def delete(pk)
  user = ArUser.first(pk).first
  user.destroy
  user.destroyed?
end

#get(hash) ⇒ Object



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

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

#set(attributes) ⇒ Object



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

def set(attributes)
  user = ArUser.new attributes
  user.save
  self.new user
end

#set!(attributes) ⇒ Object



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

def set!(attributes)
  user = ArUser.new attributes
  user.save!
  self.new user
end