Sha256: eb0745719aa1761cae01b34b58695b10fea6bb57c63db99784ab39a2e3208dfd

Contents?: true

Size: 505 Bytes

Versions: 2

Compression:

Stored size: 505 Bytes

Contents

module JSON
  module Generator
    class ObjectAttribute < BasicAttribute
      def generate
        return nil unless required?
        return {} unless @attributes.has_key?('properties')

        @attributes['properties'].inject({}) do |json, (property_name, property_attributes)|
          attribute = AttributeFactory.create(property_attributes)
          if attribute.required?
            json[property_name] = attribute.generate
          end
          json
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

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