fluke/devops-service/db/mongo/models/stack_template/stack_template_base.rb

44 lines
924 B
Ruby
Raw Normal View History

2015-02-12 13:01:05 +03:00
require 'tempfile'
require 'securerandom'
2015-03-06 12:20:30 +03:00
module Devops
module Model
class StackTemplateBase < MongoModel
2015-02-12 13:01:05 +03:00
attr_accessor :id, :template_body, :provider
2015-02-12 13:01:05 +03:00
2015-03-06 12:20:30 +03:00
types id: {type: String, empty: false},
provider: {type: String, empty: false},
template_body: {type: String, empty: false}
2015-02-12 13:01:05 +03:00
2015-03-06 12:20:30 +03:00
def initialize(attrs)
self.id = attrs['id']
self.template_body = attrs['template_body']
2015-03-06 12:20:30 +03:00
self.provider = attrs['provider']
self
end
2015-02-12 13:01:05 +03:00
2015-03-06 12:20:30 +03:00
def to_hash_without_id
{
provider: provider,
template_body: template_body
2015-03-06 12:20:30 +03:00
}
end
2015-02-12 13:01:05 +03:00
2015-03-06 12:20:30 +03:00
# attrs should include:
# - id (String)
# - provider (String)
# - template_body (String)
2015-03-06 12:20:30 +03:00
def self.create(attrs)
new(attrs)
end
2015-02-12 13:01:05 +03:00
2015-03-06 12:20:30 +03:00
def self.build_from_bson(attrs)
attrs['id'] = attrs["_id"]
self.new(attrs)
end
2015-02-12 13:01:05 +03:00
2015-03-06 12:20:30 +03:00
end
2015-02-12 13:01:05 +03:00
end
end