Class: Hanami::Mongoid::Repository
- Inherits:
-
Object
- Object
- Hanami::Mongoid::Repository
- Defined in:
- lib/hanami/mongoid/repository.rb
Class Method Summary collapse
-
.model_klass ⇒ Class
Model class.
Instance Method Summary collapse
-
#method ⇒ Object
Forwards common repository methods to the model’s collection.
Class Method Details
.model_klass ⇒ Class
Model class
9 10 11 |
# File 'lib/hanami/mongoid/repository.rb', line 9 def self.model_klass Object.const_get self.name.gsub('Repository', '') end |
Instance Method Details
#method ⇒ Object
Forwards common repository methods to the model’s collection
15 16 17 18 19 20 21 |
# File 'lib/hanami/mongoid/repository.rb', line 15 %i( find where any_of all first last new create update_all destroy_all delete_all ).each do |method| define_singleton_method method do |*args| puts self.inspect self.model_klass.send method, *args end end |