Sha256: 120d7e060b27b8bc5ea442ad9c16e0b48df4ad5f39a5d59613fef3aa5123ee6a

Contents?: true

Size: 766 Bytes

Versions: 20

Compression:

Stored size: 766 Bytes

Contents

module Rundock
  class OperationFactory
    OperationNotImplementedError = Class.new(NotImplementedError)

    def self.instance(type)
      self.new(type)
    end

    def initialize(type)
      @type = type
    end

    def create(instruction, attributes)
      klass = "Rundock::Operation::#{@type.to_s.to_camel_case}"
      Logger.debug("initialize #{klass} operation")
      raise OperationNotImplementedError unless Rundock::Operation::Base.subclasses.map(&:to_s).include?(klass)

      obj = nil
      klass.split('::').map do |k|
        obj = if obj.nil?
                Kernel.const_get(k)
              else
                obj.const_get(k)
              end
      end

      operation = obj.new(instruction, attributes)
      operation
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rundock-1.2.1 lib/rundock/operation_factory.rb
rundock-1.2.0 lib/rundock/operation_factory.rb
rundock-1.1.7 lib/rundock/operation_factory.rb
rundock-1.1.6 lib/rundock/operation_factory.rb
rundock-1.1.5 lib/rundock/operation_factory.rb
rundock-1.1.4 lib/rundock/operation_factory.rb
rundock-1.1.3 lib/rundock/operation_factory.rb
rundock-1.1.2 lib/rundock/operation_factory.rb
rundock-1.1.1 lib/rundock/operation_factory.rb
rundock-1.1.0 lib/rundock/operation_factory.rb
rundock-1.0.8 lib/rundock/operation_factory.rb
rundock-1.0.7 lib/rundock/operation_factory.rb
rundock-1.0.6 lib/rundock/operation_factory.rb
rundock-1.0.5 lib/rundock/operation_factory.rb
rundock-1.0.4 lib/rundock/operation_factory.rb
rundock-1.0.2 lib/rundock/operation_factory.rb
rundock-1.0.1 lib/rundock/operation_factory.rb
rundock-1.0.0 lib/rundock/operation_factory.rb
rundock-0.5.8 lib/rundock/operation_factory.rb
rundock-0.5.7 lib/rundock/operation_factory.rb