Sha256: 6be37d5c10283b912bc4ab3f9011b05213cb30965de85845eb65431130c1b42f

Contents?: true

Size: 727 Bytes

Versions: 1

Compression:

Stored size: 727 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'aequitas/rule'

module Aequitas
  class Rule
    class PrimitiveType < Rule

      attr_reader :primitive

      def initialize(attribute_name, options = {})
        super

        @primitive = options.fetch(:primitive)
      end

      def valid?(resource)
        value = attribute_value(resource)

        skip?(value) || primitive?(value)
      end

      def primitive?(value)
        value.is_a?(primitive)
      end

      def violation_type(resource)
        :primitive
      end

      def violation_data(resource)
        [ [ :primitive, primitive ] ]
      end

    end # class PrimitiveType
  end # class Rule
end # module Aequitas

require 'aequitas/rule/primitive_type/virtus'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aequitas-0.0.2 lib/aequitas/rule/primitive_type.rb