Sha256: 45c75faf74d705b71cccf9faf217732777fe928d37ff2cbb4ee73f488e00a3d7

Contents?: true

Size: 916 Bytes

Versions: 1

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

require 'rancher/api/models/machine/driver_config'

module Rancher
  module Api
    module Helpers
      module Machine
        DIGITAL_OCEAN = 'digitalocean'
        VMWARE_VSPHERE = 'vmwarevsphere'

        def self.included(base)
          base.extend(ClassMethods)
        end

        module ClassMethods
          def transitioning
            all.select { |m| m.transitioning.eql?('yes') }
          end

          def active
            where(state: 'active')
          end
        end

        def driver_config
          case driver
          when DIGITAL_OCEAN, VMWARE_VSPHERE
            DriverConfig.new(attributes["#{driver}Config"])
          end
        end

        def driver_config=(dc)
          case driver
          when DIGITAL_OCEAN, VMWARE_VSPHERE
            attributes["#{driver}Config"] = dc.attributes
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rancher-api-beta-0.8.1 lib/rancher/api/helpers/machine.rb