Sha256: a1d6f9495ee2a1c212ae0984ea9de8f892936625f7f79184b7c369fd0092f19d

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 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
        Payloads::JsonStringPayload.new([arg])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-ray-0.4.1 lib/ray/payload_factory.rb