Module: ROM::Initializer::DefineWithHook Private
- Defined in:
- core/lib/rom/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
- #param ⇒ 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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'core/lib/rom/initializer.rb', line 25 def __define_with__ seq_names = dry_initializer .definitions .reject { |_, d| d.option } .keys .join(', ') seq_names << ', ' unless seq_names.empty? undef_method(:with) if method_defined?(:with) class_eval(<<-RUBY, __FILE__, __LINE__ + 1) def with(**new_options) if new_options.empty? self else self.class.new(#{seq_names}**options, **new_options) end end RUBY end |
#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 |
# File 'core/lib/rom/initializer.rb', line 17 def option(*) super.tap do __define_with__ unless method_defined?(:with) end 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.
11 12 13 |
# File 'core/lib/rom/initializer.rb', line 11 def param(*) super.tap { __define_with__ } end |