Sha256: 3b7339b593513fe0d6c672ec8fc070eb9256c7f9ec13ea7c7b1bf73bc0194bde

Contents?: true

Size: 721 Bytes

Versions: 12

Compression:

Stored size: 721 Bytes

Contents

# Abstract type for the 'numeric' family

module Attributor
  module Numeric
    extend ActiveSupport::Concern
    include Type

    module ClassMethods
      
      def native_type
        raise NotImplementedError
      end

      def family
        'numeric'
      end

      def as_json_schema( shallow: false, example: nil, attribute_options: {} )
        h = super
        opts = ( self.respond_to?(:options) ) ? self.options.merge( attribute_options ) : attribute_options
        h[:minimum] = opts[:min] if opts[:min]
        h[:maximum] = opts[:max] if opts[:max]
        # We're not explicitly setting false to exclusiveMinimum and exclusiveMaximum (as that's the default)
        h
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
attributor-8.0 lib/attributor/families/numeric.rb
attributor-7.1 lib/attributor/families/numeric.rb
attributor-7.0 lib/attributor/families/numeric.rb
attributor-6.5 lib/attributor/families/numeric.rb
attributor-6.4 lib/attributor/families/numeric.rb
attributor-6.3 lib/attributor/families/numeric.rb
attributor-6.2 lib/attributor/families/numeric.rb
attributor-6.1 lib/attributor/families/numeric.rb
attributor-6.0 lib/attributor/families/numeric.rb
attributor-5.7 lib/attributor/families/numeric.rb
attributor-5.6 lib/attributor/families/numeric.rb
attributor-5.5 lib/attributor/families/numeric.rb