Sha256: ea19079b0c5463f0d8afe14a2a0eda16c3b5199348adcf4b29c26b870af6ef24

Contents?: true

Size: 602 Bytes

Versions: 4

Compression:

Stored size: 602 Bytes

Contents

module Restspec
  module Schema
    class SchemaExample
      attr_accessor :schema, :extensions

      def initialize(schema, extensions = {})
        self.schema = schema
        self.extensions = extensions
      end

      def value
        attributes.inject({}) do |sample, (_, attribute)|
          if attribute.can_generate_examples?
            sample.merge(attribute.name => AttributeExample.new(attribute).value)
          else
            sample
          end
        end.merge(extensions)
      end

      private

      def attributes
        schema.attributes
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
restspec-0.0.4 lib/restspec/schema/schema_example.rb
restspec-0.0.3 lib/restspec/schema/schema_example.rb
restspec-0.0.2 lib/restspec/schema/schema_example.rb
restspec-0.0.1 lib/restspec/schema/schema_example.rb