Sha256: 9b5130fbb08b39ddf962b9fd7792dabe4ed9fe41a5a520dadd049a791095ade5

Contents?: true

Size: 451 Bytes

Versions: 4

Compression:

Stored size: 451 Bytes

Contents

module Compel
  module Builder

    class Schema

      include Builder::Common

      attr_reader :type,
                  :options

      def initialize(type)
        @type = type
        @options = Hashie::Mash.new
      end

      def required?
        !!options[:required]
      end

      def default_value
        options[:default]
      end

      def validate(object)
        Contract.new(object, self).validate
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
compel-0.3.6 lib/compel/builder/schema.rb
compel-0.3.4 lib/compel/builder/schema.rb
compel-0.3.2 lib/compel/builder/schema.rb
compel-0.3.1 lib/compel/builder/schema.rb