Module: Rmodel::Mongo::RepositoryExt::Queryable
- Included in:
- Rmodel::Mongo::Repository
- Defined in:
- lib/rmodel/mongo/repository_ext/queryable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #execute_query(selector, options) ⇒ Object
- #find_by_query(selector, options) ⇒ Object
- #query ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/rmodel/mongo/repository_ext/queryable.rb', line 6 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#execute_query(selector, options) ⇒ Object
20 21 22 |
# File 'lib/rmodel/mongo/repository_ext/queryable.rb', line 20 def execute_query(selector, ) @client[@collection].find(selector, ) end |
#find_by_query(selector, options) ⇒ Object
14 15 16 17 18 |
# File 'lib/rmodel/mongo/repository_ext/queryable.rb', line 14 def find_by_query(selector, ) execute_query(selector, ).map do |hash| @factory.fromHash(hash) end end |
#query ⇒ Object
10 11 12 |
# File 'lib/rmodel/mongo/repository_ext/queryable.rb', line 10 def query (self.class.query_klass ||= Class.new(Query)).new(self) end |