Class: Inquirex::SafeSource::CallSpec
- Inherits:
-
Data
- Object
- Data
- Inquirex::SafeSource::CallSpec
- Defined in:
- lib/inquirex/safe_source/call_spec.rb
Overview
The shape a single allowlisted DSL call may take, built by Vocabulary.allow and consumed by Validator. Its three members:
positional— accepted positional arguments. An Array names each slot's kind in order ([:symbol]);{ repeat: kind, min: n }accepts any number of arguments of one kind;{ optional: kind }accepts zero or one.keywords—nilwhen the call takes no keyword arguments, or a Hash mapping each accepted keyword to its value kind. The key Vocabulary::ANY_OTHER sets the kind for every keyword not named explicitly, and is only legitimate when the real method takes**rest.block—:forbidden; the name of the nested scope whose vocabulary the block's statements are validated against; or{ optional: scope }for a call that accepts that block but does not require it, mirroring thepositionalspelling.send_emailis the optional case: it takes its fields either as keywords or from a block.
Value kinds are :literal, :string, :symbol, :type_name and :rule.
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#positional ⇒ Object
readonly
Returns the value of attribute positional.
Instance Method Summary collapse
-
#block_scope ⇒ Symbol?
The scope this call's block opens, with
{ optional: scope }unwrapped, or nil when the call takes no block at all.
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block
27 28 29 |
# File 'lib/inquirex/safe_source/call_spec.rb', line 27 def block @block end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords
27 28 29 |
# File 'lib/inquirex/safe_source/call_spec.rb', line 27 def keywords @keywords end |
#positional ⇒ Object (readonly)
Returns the value of attribute positional
27 28 29 |
# File 'lib/inquirex/safe_source/call_spec.rb', line 27 def positional @positional end |
Instance Method Details
#block_scope ⇒ Symbol?
The scope this call's block opens, with { optional: scope }
unwrapped, or nil when the call takes no block at all. Callers that
care whether the block is required read #block itself.
33 34 35 36 37 38 39 |
# File 'lib/inquirex/safe_source/call_spec.rb', line 33 def block_scope case block when :forbidden then nil when Hash then block[:optional] else block end end |