Module: FastMcp::RuleTypeDetector
- Included in:
- SchemaCompiler
- Defined in:
- lib/mcp/tool.rb
Overview
Module for handling rule type detection
Instance Method Summary collapse
-
#array_type?(rule) ⇒ Boolean
Check if a rule is for an array type.
-
#direct_hash_predicate?(rule) ⇒ Boolean
Check for direct hash predicate.
-
#hash_type?(rule) ⇒ Boolean
Check if a rule is for a hash type.
-
#nested_hash_predicate?(rule) ⇒ Boolean
Check for nested hash predicate.
Instance Method Details
#array_type?(rule) ⇒ Boolean
Check if a rule is for an array type
352 353 354 355 |
# File 'lib/mcp/tool.rb', line 352 def array_type?(rule) rule.is_a?(Dry::Logic::Operations::And) && rule.rules.any? { |r| r.respond_to?(:name) && r.name == :array? } end |
#direct_hash_predicate?(rule) ⇒ Boolean
Check for direct hash predicate
331 332 333 334 335 |
# File 'lib/mcp/tool.rb', line 331 def direct_hash_predicate?(rule) return false unless rule.is_a?(Dry::Logic::Operations::And) rule.rules.any? { |r| r.respond_to?(:name) && r.name == :hash? } end |
#hash_type?(rule) ⇒ Boolean
Check if a rule is for a hash type
324 325 326 327 328 |
# File 'lib/mcp/tool.rb', line 324 def hash_type?(rule) return true if direct_hash_predicate?(rule) || nested_hash_predicate?(rule) false end |
#nested_hash_predicate?(rule) ⇒ Boolean
Check for nested hash predicate
338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/mcp/tool.rb', line 338 def nested_hash_predicate?(rule) if rule.is_a?(Dry::Logic::Operations::Key) && rule.rule.is_a?(Dry::Logic::Operations::And) return rule.rule.rules.any? { |r| r.respond_to?(:name) && r.name == :hash? } end if rule.respond_to?(:right) && rule.right.is_a?(Dry::Logic::Operations::Key) && rule.right.rule.is_a?(Dry::Logic::Operations::And) return rule.right.rule.rules.any? { |r| r.respond_to?(:name) && r.name == :hash? } end false end |