28 lines
		
	
	
		
			507 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			507 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| module Devops
 | |
|   module Model
 | |
|     class EnvironmentsArray < ::Array
 | |
| 
 | |
|       class << self
 | |
| 
 | |
|         def demongoize(object)
 | |
|           object ? object.map{ |obj| obj.is_a?(Environment) ? obj : Environment.new(obj) } : new
 | |
|         end
 | |
| 
 | |
|         def evolve(object)
 | |
|           if object.is_a?(EnvironmentsArray) or object.is_a?(Array)
 | |
|             object.map(&:to_hash)
 | |
|           else
 | |
|             object
 | |
|           end
 | |
|         end
 | |
| 
 | |
|       end
 | |
| 
 | |
|       def mongoize
 | |
|         self.map(&:to_hash)
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 | |
| 
 | 
