Class: Meta::Utils::Kwargs::Builder
- Inherits:
-
Object
- Object
- Meta::Utils::Kwargs::Builder
- Defined in:
- lib/meta/utils/kwargs/builder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_handler(&blk) ⇒ Object
- #build(base_consumer = nil) ⇒ Object
- #handle_extras(sym) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #key(*names, **options) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
29 30 31 32 |
# File 'lib/meta/utils/kwargs/builder.rb', line 29 def initialize @arguments = [] @handle_extras = ExtrasConsumers::RaiseError end |
Class Method Details
Instance Method Details
#after_handler(&blk) ⇒ Object
44 45 46 |
# File 'lib/meta/utils/kwargs/builder.rb', line 44 def after_handler(&blk) @after_handler = blk end |
#build(base_consumer = nil) ⇒ Object
48 49 50 51 52 |
# File 'lib/meta/utils/kwargs/builder.rb', line 48 def build(base_consumer = nil) consumers = [base_consumer, *@arguments].compact consumers = CompositeConsumer.new(*consumers) Checker.new(arguments_consumer: consumers, extras_consumer: @handle_extras, after_handler: @after_handler) end |
#handle_extras(sym) ⇒ Object
40 41 42 |
# File 'lib/meta/utils/kwargs/builder.rb', line 40 def handle_extras(sym) @handle_extras = ExtrasConsumers.resolve_handle_extras(sym) end |
#key(*names, **options) ⇒ Object
34 35 36 37 38 |
# File 'lib/meta/utils/kwargs/builder.rb', line 34 def key(*names, **) names.each do |name| @arguments << ArgumentConsumer.new(name: name, **) end end |