Sha256: 502caf43c0d85c7346dab4a03382c29954fcb2b0348a22e853783beedaac2f4d

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

module Restspec
  module Schema
    class Attribute
      attr_reader :name, :type

      def initialize(name, type, options = {})
        self.name = name
        self.type = type
        self.example_override = options.fetch(:example, nil)
        self.allowed_abilities = options.fetch(:for, [:checks, :examples])
      end

      def example
        @example ||= example_override
      end

      def can_generate_examples?
        allowed_abilities.include?(:examples)
      end

      def can_be_checked?
        allowed_abilities.include?(:checks)
      end

      private

      attr_writer :name, :type
      attr_accessor :example_override, :allowed_abilities
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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