fluke/devops-service/db/mongo/models/stack_template/stack_template_base.rb
2015-04-16 18:55:26 +04:00

44 lines
924 B
Ruby

require 'tempfile'
require 'securerandom'
module Devops
module Model
class StackTemplateBase < MongoModel
attr_accessor :id, :template_body, :provider
types id: {type: String, empty: false},
provider: {type: String, empty: false},
template_body: {type: String, empty: false}
def initialize(attrs)
self.id = attrs['id']
self.template_body = attrs['template_body']
self.provider = attrs['provider']
self
end
def to_hash_without_id
{
provider: provider,
template_body: template_body
}
end
# attrs should include:
# - id (String)
# - provider (String)
# - template_body (String)
def self.create(attrs)
new(attrs)
end
def self.build_from_bson(attrs)
attrs['id'] = attrs["_id"]
self.new(attrs)
end
end
end
end