Class: Qonfig::DataSet

Inherits:
Object
  • Object
show all
Extended by:
DSL
Defined in:
lib/qonfig/data_set.rb,
lib/qonfig/data_set/class_builder.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Modules: ClassBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

commands, compose, extended, load_from_env, load_from_self, load_from_yaml, setting

Constructor Details

#initialize(options_map = {}, &configurations) ⇒ DataSet

Returns a new instance of DataSet.

Parameters:

  • options_map (Hash) (defaults to: {})
  • configurations (Proc)

Since:

  • 0.1.0



21
22
23
24
25
26
# File 'lib/qonfig/data_set.rb', line 21

def initialize(options_map = {}, &configurations)
  @__access_lock__ = Mutex.new
  @__definition_lock__ = Mutex.new

  thread_safe_definition { load!(options_map, &configurations) }
end

Instance Attribute Details

#settingsQonfig::Settings (readonly)

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.

Returns:

Since:

  • 0.1.0



14
15
16
# File 'lib/qonfig/data_set.rb', line 14

def settings
  @settings
end

Instance Method Details

#[](key) ⇒ Object

Parameters:

  • key (String, Symbol)

Returns:

  • (Object)

Since:

  • 0.2.0



85
86
87
# File 'lib/qonfig/data_set.rb', line 85

def [](key)
  thread_safe_access { settings[key] }
end

#clear!void

This method returns an undefined value.

Since:

  • 0.2.0



102
103
104
# File 'lib/qonfig/data_set.rb', line 102

def clear!
  thread_safe_access { settings.__clear__ }
end

#configure(options_map = {}) ⇒ void

This method returns an undefined value.

Parameters:

  • options_map (Hash) (defaults to: {})

Since:

  • 0.1.0



64
65
66
67
68
69
# File 'lib/qonfig/data_set.rb', line 64

def configure(options_map = {})
  thread_safe_access do
    settings.__apply_values__(options_map)
    yield(settings) if block_given?
  end
end

#dig(*keys) ⇒ Object

Parameters:

  • keys (Array<String, Symbol>)

Returns:

  • (Object)

Since:

  • 0.2.0



94
95
96
# File 'lib/qonfig/data_set.rb', line 94

def dig(*keys)
  thread_safe_access { settings.__dig__(*keys) }
end

#freeze!void

This method returns an undefined value.

Since:

  • 0.1.0



32
33
34
# File 'lib/qonfig/data_set.rb', line 32

def freeze!
  thread_safe_access { settings.__freeze__ }
end

#frozen?void

This method returns an undefined value.

Since:

  • 0.2.0



40
41
42
# File 'lib/qonfig/data_set.rb', line 40

def frozen?
  thread_safe_access { settings.__is_frozen__ }
end

#reload!(options_map = {}, &configurations) ⇒ void

This method returns an undefined value.

Parameters:

  • options_map (Hash) (defaults to: {})
  • configurations (Proc)

Raises:

Since:

  • 0.2.0



52
53
54
55
56
57
# File 'lib/qonfig/data_set.rb', line 52

def reload!(options_map = {}, &configurations)
  thread_safe_definition do
    raise Qonfig::FrozenSettingsError, 'Frozen config can not be reloaded' if frozen?
    load!(options_map, &configurations)
  end
end

#to_hHash Also known as: to_hash

Returns:

  • (Hash)

Since:

  • 0.1.0



75
76
77
# File 'lib/qonfig/data_set.rb', line 75

def to_h
  thread_safe_access { settings.__to_hash__ }
end