Module: Qonfig::DataSet::ClassBuilder Private

Defined in:
lib/qonfig/data_set/class_builder.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.

Since:

  • 0.2.0

Class Method Summary collapse

Class Method Details

.build_from_hash(hash) ⇒ Class<Qonfig::DataSet>

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.

See Also:

Since:

  • 0.2.0



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/qonfig/data_set/class_builder.rb', line 14

def build_from_hash(hash)
  Class.new(Qonfig::DataSet).tap do |data_set_klass|
    hash.each_pair do |key, value|
      if value.is_a?(Hash) && value.any?
        sub_data_set_klass = build_from_hash(value)
        data_set_klass.setting(key) { compose sub_data_set_klass }
      else
        data_set_klass.setting key, value
      end
    end
  end
end

.inherit(base_klass:, child_klass:) ⇒ void

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.

This method returns an undefined value.

Options Hash (base_klass:):

Options Hash (child_klass:):

Since:

  • 0.19.0



33
34
35
36
37
38
# File 'lib/qonfig/data_set/class_builder.rb', line 33

def inherit(base_klass:, child_klass:)
  child_klass.definition_commands.concat(base_klass.definition_commands)
  child_klass.instance_commands.concat(base_klass.instance_commands, &:inheritable?)
  child_klass.predefined_validators.merge(base_klass.predefined_validators)
  child_klass.validators.concat(base_klass.validators)
end