Class: Dry::Schema::NamespacedRule Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/schema/namespaced_rule.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A special rule type that is configured under a specified namespace

This is used internally to create rules that can be properly handled by the message compiler in situations where a schema reuses another schema but it is configured to use a message namespace

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, rule) ⇒ NamespacedRule

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NamespacedRule.



20
21
22
23
# File 'lib/dry/schema/namespaced_rule.rb', line 20

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

Instance Attribute Details

#namespaceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/dry/schema/namespaced_rule.rb', line 17

def namespace
  @namespace
end

#ruleObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
# File 'lib/dry/schema/namespaced_rule.rb', line 14

def rule
  @rule
end

Instance Method Details

#ast(input = Undefined) ⇒ Object Also known as: to_ast

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/dry/schema/namespaced_rule.rb', line 32

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

#call(input) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
29
# File 'lib/dry/schema/namespaced_rule.rb', line 26

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