Class: Dry::Validation::Rust::MacroRegistry Private
- Inherits:
-
Object
- Object
- Dry::Validation::Rust::MacroRegistry
- Defined in:
- lib/dry/validation/rust/macros.rb
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.
Instance Method Summary collapse
- #fetch(name) ⇒ Object private
-
#initialize(parent = nil) ⇒ MacroRegistry
constructor
private
A new instance of MacroRegistry.
- #key?(name) ⇒ Boolean private
- #register(name, *args, &block) ⇒ Object private
Constructor Details
#initialize(parent = nil) ⇒ MacroRegistry
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 MacroRegistry.
17 18 19 20 |
# File 'lib/dry/validation/rust/macros.rb', line 17 def initialize(parent = nil) @parent = parent @entries = {} end |
Instance Method Details
#fetch(name) ⇒ 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.
35 36 37 |
# File 'lib/dry/validation/rust/macros.rb', line 35 def fetch(name) @entries.fetch(name.to_sym) { @parent&.fetch(name) || raise(KeyError, "unknown macro: #{name}") } end |
#key?(name) ⇒ Boolean
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.
39 40 41 |
# File 'lib/dry/validation/rust/macros.rb', line 39 def key?(name) @entries.key?(name.to_sym) || @parent&.key?(name) end |
#register(name, *args, &block) ⇒ 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.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dry/validation/rust/macros.rb', line 22 def register(name, *args, &block) raise ArgumentError, 'a macro block is required' unless block keyword_params = BlockKeywordParameters.extract(block) @entries[name.to_sym] = Macro.new( name: name.to_sym, args: args, block: block, keyword_params: keyword_params ) self end |