Module: Waves::Layers::ORM::Sequel::ControllerMethods

Defined in:
lib/waves/layers/orm/providers/sequel.rb

Overview

Mixed into Waves::Controllers::Base. Provides ORM-specific helper methods for model access.

Instance Method Summary collapse

Instance Method Details

#allObject



62
63
64
# File 'lib/waves/layers/orm/providers/sequel.rb', line 62

def all
  model.all
end

#create(attrs = nil) ⇒ Object



70
71
72
73
# File 'lib/waves/layers/orm/providers/sequel.rb', line 70

def create(attrs = nil)
  ats = attrs || attributes
  model.create( ats.to_hash )
end

#delete(name) ⇒ Object



75
76
77
# File 'lib/waves/layers/orm/providers/sequel.rb', line 75

def delete( name )
  find( name ).destroy
end

#find(name) ⇒ Object



66
67
68
# File 'lib/waves/layers/orm/providers/sequel.rb', line 66

def find( name )
  model[ :name => name ] or not_found
end

#update(name) ⇒ Object



79
80
81
82
83
# File 'lib/waves/layers/orm/providers/sequel.rb', line 79

def update( name )
  instance = find( name )
  instance.update_with_params( attributes.to_hash )
  instance
end