Sha256: ce9ec40a0df587ae7ff126d440cf6359f8332396d7236e7b99d04c23af0213eb

Contents?: true

Size: 596 Bytes

Versions: 4

Compression:

Stored size: 596 Bytes

Contents

module Ray
  class PayloadFactory
    attr_reader :arg

    def self.create_for_values(args)
      args.map do |arg|
        new(arg).get_payload
      end
    end

    def initialize(arg)
      @arg = arg
    end

    def get_payload
      case arg
      when Integer
        Payloads::IntPayload.new(arg)
      when NilClass
        Payloads::NullPayload.new(arg)
      when TrueClass, FalseClass
        Payloads::BoolPayload.new(arg)
      when String
        Payloads::StringPayload.new(arg)
      else
        raise StandardError, "Unable to match payload type"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-ray-0.4.0 lib/ray/payload_factory.rb
ruby-ray-0.3.0 lib/ray/payload_factory.rb
ruby-ray-0.2.0 lib/ray/payload_factory.rb
ruby-ray-0.1.0 lib/ray/payload_factory.rb