Class: GrapeOAS::Introspectors::DryIntrospectorSupport::PredicateHandler
- Inherits:
-
Object
- Object
- GrapeOAS::Introspectors::DryIntrospectorSupport::PredicateHandler
- Defined in:
- lib/grape_oas/introspectors/dry_introspector_support/predicate_handler.rb
Overview
Handles Dry::Schema predicate nodes and updates constraints accordingly.
Constant Summary collapse
- HANDLED_PREDICATES =
%i[ key? size? min_size? max_size? range? empty? bytesize? max_bytesize? min_bytesize? maybe nil? filled? included_in? excluded_from? eql? true? false? gt? gteq? min? lt? lteq? max? multiple_of? divisible_by? format? uuid? uri? url? email? date? time? date_time? str? int? array? hash? number? float? bool? boolean? type? odd? even? ].freeze
Instance Method Summary collapse
- #handle(pred_node) ⇒ Object
-
#initialize(constraints) ⇒ PredicateHandler
constructor
A new instance of PredicateHandler.
Constructor Details
#initialize(constraints) ⇒ PredicateHandler
Returns a new instance of PredicateHandler.
8 9 10 |
# File 'lib/grape_oas/introspectors/dry_introspector_support/predicate_handler.rb', line 8 def initialize(constraints) @constraints = constraints end |
Instance Method Details
#handle(pred_node) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/grape_oas/introspectors/dry_introspector_support/predicate_handler.rb', line 22 def handle(pred_node) return unless pred_node.is_a?(Array) name = pred_node[0] args = Array(pred_node[1]) dispatch_predicate(name, args) constraints.unhandled_predicates << name unless HANDLED_PREDICATES.include?(name) end |