Module: SequelAdapter::ClassMethods

Defined in:
lib/models/sequel_adapter.rb

Instance Method Summary collapse

Instance Method Details

#allObject



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

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

#delete(pk) ⇒ Object



37
38
39
40
41
# File 'lib/models/sequel_adapter.rb', line 37

def delete(pk)
  user = SequelUser.first(:id => pk)
  user.destroy
  !user.exists?
end

#get(hash) ⇒ Object



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

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

#set(attributes) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/models/sequel_adapter.rb', line 21

def set(attributes)
  user = SequelUser.new attributes
  if user.valid?
    user.save
    #false
  end

  self.new user
end

#set!(attributes) ⇒ Object



31
32
33
34
35
# File 'lib/models/sequel_adapter.rb', line 31

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