2015-02-12 13:01:05 +03:00
|
|
|
module Connectors
|
|
|
|
|
class Stack < Base
|
|
|
|
|
include Helpers::InsertCommand,
|
|
|
|
|
Helpers::ShowCommand,
|
|
|
|
|
Helpers::ListCommand,
|
|
|
|
|
Helpers::DeleteCommand
|
|
|
|
|
|
|
|
|
|
def initialize(db)
|
|
|
|
|
self.collection = db.collection('stacks')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def stacks(provider=nil)
|
|
|
|
|
query = (provider.nil? ? {} : {'provider' => provider})
|
|
|
|
|
list(query)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def model_from_bson(bson)
|
|
|
|
|
provider = bson['provider']
|
2015-02-18 11:00:24 +03:00
|
|
|
::StackFactory.get_class(provider).build_from_bson(bson)
|
2015-02-12 13:01:05 +03:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|