Module: ROM::Initializer::DefineWithHook Private

Defined in:
lib/rom/initializer.rb

Overview

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.

API:

  • private

Instance Method Summary collapse

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.

API:

  • private



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)

#optionObject

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.

API:

  • private



16
17
18
19
20
# File 'lib/rom/initializer.rb', line 16

def option(*)
  super.tap do
    __define_with__ unless method_defined?(:with)
  end
end

#paramObject

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.

API:

  • private



11
12
13
# File 'lib/rom/initializer.rb', line 11

def param(*)
  super.tap { __define_with__ }
end