Module: Waves::Layers::ORM::ActiveRecord::ControllerMethods

Defined in:
lib/layers/orm/active_record.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#allObject



66
67
68
# File 'lib/layers/orm/active_record.rb', line 66

def all
  model.find(:all)
end

#createObject



74
75
76
# File 'lib/layers/orm/active_record.rb', line 74

def create
  model.create( attributes )
end

#delete(id) ⇒ Object



78
79
80
# File 'lib/layers/orm/active_record.rb', line 78

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

#find(id) ⇒ Object



70
71
72
# File 'lib/layers/orm/active_record.rb', line 70

def find( id )
  model.find(id) or not_found
end

#update(id) ⇒ Object



82
83
84
85
86
# File 'lib/layers/orm/active_record.rb', line 82

def update( id )
  instance = find( id )
  instance.update_attributes( attributes )
  instance
end