Sha256: c1a4c56b74d4a9588df558c71773709d4a77703dcbdb9384ad26f70e2bda9694

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class Wco::Appliance
  include Mongoid::Document
  include Mongoid::Timestamps

  field :kind
  validates :kind, presence: true

  field :environment

  field :name
  validates :name, uniqueness: { scope: :leadset_id }, presence: true

  # field :service_name
  def service_name
    # "#{@appliance[:kind]}_#{@appliance[:environment]}_#{@appliance[:name]}"
    "#{kind}_#{environment}_#{name}"
  end


  field :subdomain
  field :domain
  def origin
    "#{subdomain}.#{domain}"
  end

  field :leadset_id # old sql
  belongs_to :leadset, class_name: 'Wco::Leadset', inverse_of: :appliances

  belongs_to :appliance_tmpl, class_name: 'Wco::ApplianceTmpl'
  def tmpl
    appliance_tmpl
  end

  belongs_to :serverhost,     class_name: 'Wco::Serverhost'


  field :port

  STATE_PENDING = 'state-pending'
  STATE_LIVE    = 'state-live'
  STATE_TERM    = 'state-term'
  STATES = %w| state-pending state-live state-term |
  field :state, default: STATE_PENDING

  def route53_zone
    Wco::DnsDomain.find_by({ name: domain })[0].route53_zone
  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ish_models-3.0.0.1 lib/wco/appliance.rb