Sha256: dbe3d4e153352594f13d3e0c291d4a86cfba87d18f2156ea079f6470c8c519a1

Contents?: true

Size: 429 Bytes

Versions: 2

Compression:

Stored size: 429 Bytes

Contents

module JSON
  module Generator
    class AttributeFactory
      CLASSES = {
        'string' => StringAttribute,
        'object' => ObjectAttribute,
        'integer' => IntegerAttribute,
        'array' => ArrayAttribute,
        'boolean' => BooleanAttribute,
        nil => EmptyAttribute
      }

      def self.create(properties)
        CLASSES[Array(properties['type']).first].new(properties)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
json-generator-0.0.1 lib/json/generator/attribute_factory.rb
contracts_api_test-0.0.1 lib/json/generator/attribute_factory.rb