Sha256: 50afca1ae19cfe5cf13218af09cd92d777735403fbcd5da7d860ed43d60006be

Contents?: true

Size: 473 Bytes

Versions: 1

Compression:

Stored size: 473 Bytes

Contents

module Dry
  module Schema
    class NamespacedRule
      attr_reader :rule

      attr_reader :namespace

      def initialize(namespace, rule)
        @namespace = namespace
        @rule = rule
      end

      def call(input)
        result = rule.call(input)
        Logic::Result.new(result.success?) { [:namespace, [namespace, result.to_ast]] }
      end

      def ast(input=Undefined)
        [:namespace, [namespace, rule.ast(input)]]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-schema-0.2.0 lib/dry/schema/namespaced_rule.rb