| 
									
										
										
										
											2015-08-14 17:48:07 +03:00
										 |  |  | require "db/mongo/models/stack_template/stack_template_factory" | 
					
						
							| 
									
										
										
										
											2015-02-12 13:01:05 +03:00
										 |  |  | module Connectors | 
					
						
							|  |  |  |   class StackTemplate < Base | 
					
						
							|  |  |  |     include Helpers::InsertCommand, | 
					
						
							|  |  |  |       Helpers::ShowCommand, | 
					
						
							|  |  |  |       Helpers::ListCommand, | 
					
						
							| 
									
										
										
										
											2015-07-15 16:25:06 +03:00
										 |  |  |       Helpers::DeleteCommand, | 
					
						
							|  |  |  |       Helpers::UpdateCommand | 
					
						
							| 
									
										
										
										
											2015-02-12 13:01:05 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def initialize(db) | 
					
						
							| 
									
										
										
										
											2015-09-21 15:54:33 +03:00
										 |  |  |       super(db) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def collection_name | 
					
						
							|  |  |  |       "stack_templates" | 
					
						
							| 
									
										
										
										
											2015-02-12 13:01:05 +03:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def stack_templates(provider=nil) | 
					
						
							|  |  |  |       query = (provider.nil? ? {} : {'provider' => provider}) | 
					
						
							|  |  |  |       list(query) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def model_from_bson(bson) | 
					
						
							|  |  |  |       provider = bson['provider'] | 
					
						
							| 
									
										
										
										
											2015-03-06 12:20:30 +03:00
										 |  |  |       Devops::Model::StackTemplateFactory.get_class(provider).build_from_bson(bson) | 
					
						
							| 
									
										
										
										
											2015-02-12 13:01:05 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | end |