Class: Mongoid::Generators::ActiveModel

Inherits:
Rails::Generators::ActiveModel
  • Object
show all
Defined in:
lib/generators/mongoid.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all(klass) ⇒ Object



16
17
18
# File 'lib/generators/mongoid.rb', line 16

def self.all(klass)
 "#{klass}.all"
end

.build(klass, params = nil) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/generators/mongoid.rb', line 24

def self.build(klass, params=nil)
 if params
   "#{klass}.new(#{params})"
 else
   "#{klass}.new"
 end
end

.find(klass, params = nil) ⇒ Object



20
21
22
# File 'lib/generators/mongoid.rb', line 20

def self.find(klass, params=nil)
 "#{klass}.find(#{params})"
end

Instance Method Details

#destroyObject



44
45
46
# File 'lib/generators/mongoid.rb', line 44

def destroy
 "#{name}.destroy"
end

#errorsObject



40
41
42
# File 'lib/generators/mongoid.rb', line 40

def errors
 "#{name}.errors"
end

#saveObject



32
33
34
# File 'lib/generators/mongoid.rb', line 32

def save
 "#{name}.save"
end

#update_attributes(params = nil) ⇒ Object



36
37
38
# File 'lib/generators/mongoid.rb', line 36

def update_attributes(params=nil)
 "#{name}.update_attributes(#{params})"
end