| 
									
										
										
										
											2015-02-12 13:01:05 +03:00
										 |  |  | module Connectors | 
					
						
							|  |  |  |   class Key < Base | 
					
						
							|  |  |  |     include Helpers::InsertCommand, | 
					
						
							|  |  |  |       Helpers::ShowCommand, | 
					
						
							|  |  |  |       Helpers::ListCommand, | 
					
						
							|  |  |  |       Helpers::DeleteCommand | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def initialize(db) | 
					
						
							|  |  |  |       self.collection = db.collection('keys') | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def key(id, scope=nil) | 
					
						
							|  |  |  |       options = scope ? {'scope' => scope} : {} | 
					
						
							|  |  |  |       show(id, options) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def key_delete id | 
					
						
							|  |  |  |       delete(id, 'scope' => ::Key::USER) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def model_from_bson(bson) | 
					
						
							| 
									
										
										
										
											2015-02-18 11:00:24 +03:00
										 |  |  |       ::Key.build_from_bson(bson) | 
					
						
							| 
									
										
										
										
											2015-02-12 13:01:05 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | end |