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

Defined in:
lib/waves/layers/orm/providers/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



57
58
59
# File 'lib/waves/layers/orm/providers/active_record.rb', line 57

def all
  model.find(:all)
end

#createObject



65
66
67
# File 'lib/waves/layers/orm/providers/active_record.rb', line 65

def create
  model.create( attributes )
end

#delete(name) ⇒ Object



69
70
71
# File 'lib/waves/layers/orm/providers/active_record.rb', line 69

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

#find(name) ⇒ Object



61
62
63
# File 'lib/waves/layers/orm/providers/active_record.rb', line 61

def find( name )
  model.find_by_name(name) or not_found
end

#update(name) ⇒ Object



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

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