Sha256: d624891ec2760e615c9a44b3e11ce72a90d74574b08e0ef5cd984db3f212425a

Contents?: true

Size: 1.16 KB

Versions: 21

Compression:

Stored size: 1.16 KB

Contents

class WcoHosting::Appliance
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Paranoia
  store_in collection: 'wco_appliances'

  has_many :logs, as: :obj, class_name: 'Wco::Log'

  belongs_to :leadset,      class_name: 'Wco::Leadset', inverse_of: :appliances
  belongs_to :subscription, class_name: 'Wco::Subscription' # , inverse_of: :appliance

  field :service_name
  before_validation :set_service_name, on: :create, unless: ->{ service_name }
  def set_service_name
    self[:service_name] = host.gsub(".", "_")
  end

  belongs_to :environment, class_name: 'WcoHosting::Environment', inverse_of: :appliances, optional: true

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

  field :n_retries, type: :integer, default: 3

  belongs_to :appliance_tmpl, class_name: 'WcoHosting::ApplianceTmpl'
  def tmpl
    appliance_tmpl
  end
  def kind
    tmpl.kind
  end

  belongs_to :serverhost,  class_name: 'WcoHosting::Serverhost'

  field :port

  STATE_PENDING = 'state-pending'
  STATE_LIVE    = 'state-live'
  STATE_TERM    = 'state-term'
  field :state, default: STATE_PENDING

  def to_s
    service_name
  end
end


Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
wco_models-3.1.0.148 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.147 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.146 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.145 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.144 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.143 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.142 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.141 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.140 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.139 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.138 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.137 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.136 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.135 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.134 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.133 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.132 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.131 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.130 app/models/wco_hosting/appliance.rb
wco_models-3.1.0.129 app/models/wco_hosting/appliance.rb