Module: Dry::Effects::Initializer::DefineWithHook Private
- Defined in:
- lib/dry/effects/initializer.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #__define_with__ ⇒ Object private
- #option ⇒ Object private
- #options? ⇒ Boolean private
- #param ⇒ Object private
- #params_arity ⇒ Object private
Instance Method Details
#__define_with__ ⇒ 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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dry/effects/initializer.rb', line 40 def __define_with__ seq_names = dry_initializer .definitions .reject { _2.option } .keys .join(", ") seq_names << ", " unless seq_names.empty? undef_method(:with) if method_defined?(:with) class_eval(" def with(**new_options) # def with(**new_options)\n if new_options.empty? # if new_options.empty?\n self # self\n else # else\n self.class.new(\#{seq_names}**options, **new_options) # self.class.new(attr1, attr2, **options, **new_options)\n end # end\n end # end\n RUBY\nend\n", __FILE__, __LINE__ + 1) |
#option ⇒ 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.
17 18 19 20 21 22 |
# File 'lib/dry/effects/initializer.rb', line 17 def option(...) super.tap do __define_with__ unless method_defined?(:with) = true end end |
#options? ⇒ 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.
33 34 35 36 37 |
# File 'lib/dry/effects/initializer.rb', line 33 def return if defined? = false end |
#param ⇒ 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.
9 10 11 12 13 14 |
# File 'lib/dry/effects/initializer.rb', line 9 def param(...) super.tap do @params_arity = nil __define_with__ end end |
#params_arity ⇒ 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.
25 26 27 28 29 30 |
# File 'lib/dry/effects/initializer.rb', line 25 def params_arity @params_arity ||= dry_initializer .definitions .reject { _2.option } .size end |