Method: ROM::Initializer::DefineWithHook#__define_with__

Defined in:
lib/rom/initializer.rb

#__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.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rom/initializer.rb', line 23

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("    def with(new_options = EMPTY_HASH)\n      if new_options.empty?\n        self\n      else\n        self.class.new(\#{ seq_names }options.merge(new_options))\n      end\n    end\n  RUBY\nend\n", __FILE__, __LINE__ + 1)