Sha256: 4fb30d54fdc5195a31a72fea9c6d977eab308c6422669495d2dc5e7c0aa70b1f

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

class Wco::ApplianceTmpl
  include Mongoid::Document
  include Mongoid::Timestamps

  field :kind
  validates :kind, uniqueness: { scope: :version }, presence: true

  field :version, type: :string, default: '0.0.0'
  validates :version, uniqueness: { scope: :kind }, presence: true
  index({ kind: -1, version: -1 }, { name: :kind_version })

  field :descr, type: :string

  field :image
  validates :image, presence: true

  field :volume_zip
  validates :volume_zip, presence: true

  ## Only underscores! These become variable names.
  # KIND_CRM        = 'kind_crm'
  # KIND_DRUPAL     = 'kind_drupal'
  # KIND_HELLOWORLD = 'kind_helloworld'
  # KIND_IROWOR     = 'kind_irowor'
  # KIND_JENKINS    = 'kind_jenkins'
  # KIND_MATOMO     = 'kind_matomo'
  # KIND_MOODLE     = 'kind_moodle'
  # KIND_PRESTASHOP = 'kind_prestashop'
  # KIND_SMT        = 'kind_smt'
  # KIND_WORDPRESS  = 'kind_wordpress'

  ## 2023-12-08 :: These names are impossible to change already.
  KIND_CRM        = 'crm'
  KIND_DRUPAL     = 'drupal'
  KIND_HELLOWORLD = 'helloworld'
  KIND_IROWOR     = 'irowor'
  KIND_JENKINS    = 'jenkins'
  KIND_MATOMO     = 'matomo'
  KIND_MOODLE     = 'moodle'
  KIND_PRESTASHOP = 'prestashop'
  KIND_SMT        = 'smt'
  KIND_WORDPRESS  = 'wordpress'

  KINDS = [ KIND_CRM, KIND_DRUPAL, KIND_HELLOWORLD, KIND_IROWOR,
    KIND_JENKINS, KIND_MATOMO, KIND_MOODLE, KIND_PRESTASHOP, KIND_SMT,
    KIND_WORDPRESS ]

  has_many :appliances, class_name: 'Wco::Appliance'

  def self.latest_of kind
    where({ kind: kind }).order_by({ version: :desc }).first
  end

end
AppTmpl = Wco::ApplianceTmpl

Version data entries

1 entries across 1 versions & 1 rubygems

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