Module: Qonfig::Imports::Export Private

Defined in:
lib/qonfig/imports/export.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.18.0

Class Method Summary collapse

Class Method Details

.export!(exportable_object, exported_config, *exported_setting_keys, mappings: Qonfig::Imports::Mappings::EMPTY_MAPPINGS, raw: Qonfig::Imports::Abstract::DEFAULT_RAW_BEHAVIOR, prefix: Qonfig::Imports::Abstract::EMPTY_PREFIX, accessor: Qonfig::Imports::Abstract::AS_ACCESSOR) ⇒ 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.

Parameters:

  • exportable_object (Object)
  • exported_config (Qonfig::DataSet)
  • exported_setting_keys (Array<String,Symbol>)
  • mappings (Hash) (defaults to: Qonfig::Imports::Mappings::EMPTY_MAPPINGS)

    a customizable set of options

  • raw (Hash) (defaults to: Qonfig::Imports::Abstract::DEFAULT_RAW_BEHAVIOR)

    a customizable set of options

  • prefix (Hash) (defaults to: Qonfig::Imports::Abstract::EMPTY_PREFIX)

    a customizable set of options

  • accessor (Hash) (defaults to: Qonfig::Imports::Abstract::AS_ACCESSOR)

    a customizable set of options

Options Hash (mappings:):

  • (Hash<String|Symbol,String|Symbol>)

Options Hash (raw:):

  • (Boolean)

Options Hash (prefix:):

  • (String, Symbol)

Options Hash (accessor:):

  • (Boolean)

Since:

  • 0.18.0

Version:

  • 0.21.0



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/qonfig/imports/export.rb', line 19

def export!(
  exportable_object,
  exported_config,
  *exported_setting_keys,
  mappings: Qonfig::Imports::Mappings::EMPTY_MAPPINGS,
  raw: Qonfig::Imports::Abstract::DEFAULT_RAW_BEHAVIOR,
  prefix: Qonfig::Imports::Abstract::EMPTY_PREFIX,
  accessor: Qonfig::Imports::Abstract::AS_ACCESSOR
)
  exportable_is_a_module = exportable_object.is_a?(Module) rescue false
  # NOTE: (rescue false (rescue NoMethodError for #is_a?))
  #   it means that #is_a? is not defined for exportable_object.
  #   it happens only with BasicObject instances.

  unless exportable_is_a_module
    # NOTE:
    #   << is a universal way for extrating the singleton class of an object
    #   cuz BasicObject has no #singelton_class method;
    exportable_object = (class << exportable_object; self; end)
  end

  Qonfig::Imports::General.import!(
    exportable_object,
    exported_config,
    *exported_setting_keys,
    prefix: prefix,
    raw: raw,
    mappings: mappings,
    accessor: accessor
  )
end