Class: Mongomatic::Generators::ActiveModel
- Inherits:
-
Rails::Generators::ActiveModel
- Object
- Rails::Generators::ActiveModel
- Mongomatic::Generators::ActiveModel
- Defined in:
- lib/rails/generators/mongomatic_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.all(klass) ⇒ Object
13 14 15 |
# File 'lib/rails/generators/mongomatic_generator.rb', line 13 def self.all(klass) "#{klass}.find" end |
.build(klass, params = nil) ⇒ Object
21 22 23 |
# File 'lib/rails/generators/mongomatic_generator.rb', line 21 def self.build(klass, params=nil) "#{klass}.new(#{params})" end |
.find(klass, params = nil) ⇒ Object
17 18 19 |
# File 'lib/rails/generators/mongomatic_generator.rb', line 17 def self.find(klass, params=nil) (params.blank?) ? "#{klass}.find" : "#{klass}.find_one(BSON::ObjectId(#{params}))" end |
Instance Method Details
#destroy ⇒ Object
37 38 39 |
# File 'lib/rails/generators/mongomatic_generator.rb', line 37 def destroy "#{name}.remove" end |
#errors ⇒ Object
33 34 35 |
# File 'lib/rails/generators/mongomatic_generator.rb', line 33 def errors "#{name}.errors" end |
#save ⇒ Object
25 26 27 |
# File 'lib/rails/generators/mongomatic_generator.rb', line 25 def save "#{name}.upsert" end |
#update_attributes(params = nil) ⇒ Object
29 30 31 |
# File 'lib/rails/generators/mongomatic_generator.rb', line 29 def update_attributes(params=nil) "#{name}.merge!(#{params})" end |