Sha256: df749e6e34cbcd7433a03c771d8fe52dc17a380032a41031a27b098fb858edb2

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module Vx
  module Builder
    class BuildConfiguration
      class Deploy

        class Base

          class << self

            @@loaded = []

            def loaded
              @@loaded
            end

            def provide(val)
              loaded.push self
              @key = val
            end

            def key
              @key
            end

            def detect(params)
              params.key?(key.to_s) if key
            end

            def module_by_key(val)
              loaded.find{|i| i.key.to_s == val.to_s }
            end
          end

          attr_reader :params, :branch

          def initialize(params)
            @params = params.is_a?(Hash) ? params : {}
            self.branch = params["branch"]
          end

          def branch=(value)
            @branch = Array(value).map(&:to_s)
          end

          def branch?(name)
            if branch.empty?
              true
            else
              branch.include?(name)
            end
          end

          def key
            if self.class.key
              @key ||= Array(params[self.class.key.to_s])
            end
          end

          def to_hash
            if key
              { self.class.key.to_s => key }
            else
              {}
            end
          end

          def to_commands
            nil
          end

        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vx-builder-0.3.1 lib/vx/builder/build_configuration/deploy/base.rb