Module: Serega::SeregaConfig::SeregaConfigInstanceMethods

Included in:
Serega::SeregaConfig
Defined in:
lib/serega/config.rb

Overview

SeregaConfig Instance methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optsHash (readonly)

Returns All config options.

Returns:

  • (Hash)

    All config options



28
29
30
# File 'lib/serega/config.rb', line 28

def opts
  @opts
end

Instance Method Details

#attribute_keysArray<Symbol>

Returns Allowed options keys for attribute initialization.

Returns:

  • (Array<Symbol>)

    Allowed options keys for attribute initialization



51
52
53
# File 'lib/serega/config.rb', line 51

def attribute_keys
  opts.fetch(:attribute_keys)
end

#check_initiate_paramsBoolean

Returns Current :check_initiate_params config option.

Returns:

  • (Boolean)

    Current :check_initiate_params config option



61
62
63
# File 'lib/serega/config.rb', line 61

def check_initiate_params
  opts.fetch(:check_initiate_params)
end

#check_initiate_params=(value) ⇒ Boolean

Returns :check_initiate_params config option.

Parameters:

  • value (Boolean)

    Set :check_initiate_params config option

Returns:

  • (Boolean)

    :check_initiate_params config option

Raises:



68
69
70
71
# File 'lib/serega/config.rb', line 68

def check_initiate_params=(value)
  raise SeregaError, "Must have boolean value, #{value.inspect} provided" if (value != true) && (value != false)
  opts[:check_initiate_params] = value
end

#from_json#call

Returns Callable that used to parse JSON.

Returns:

  • (#call)

    Callable that used to parse JSON



98
99
100
# File 'lib/serega/config.rb', line 98

def from_json
  opts.fetch(:from_json)
end

#from_json=(value) ⇒ #call

Returns Provided callable object.

Parameters:

  • value (#call)

    Callable that used to parse JSON

Returns:

  • (#call)

    Provided callable object



104
105
106
# File 'lib/serega/config.rb', line 104

def from_json=(value)
  opts[:from_json] = value
end

#initialize(opts = nil) ⇒ Object

Initializes new config instance.

Parameters:

  • opts (Hash) (defaults to: nil)

    Initial config options



35
36
37
38
# File 'lib/serega/config.rb', line 35

def initialize(opts = nil)
  opts ||= DEFAULTS
  @opts = SeregaUtils::EnumDeepDup.call(opts)
end

#initiate_keysArray<Symbol>

Returns Allowed options keys for serializer initialization.

Returns:

  • (Array<Symbol>)

    Allowed options keys for serializer initialization



46
47
48
# File 'lib/serega/config.rb', line 46

def initiate_keys
  opts.fetch(:initiate_keys)
end

#max_cached_map_per_serializer_countBoolean

Returns Current :max_cached_map_per_serializer_count config option.

Returns:

  • (Boolean)

    Current :max_cached_map_per_serializer_count config option



74
75
76
# File 'lib/serega/config.rb', line 74

def max_cached_map_per_serializer_count
  opts.fetch(:max_cached_map_per_serializer_count)
end

#max_cached_map_per_serializer_count=(value) ⇒ Boolean

Returns New :max_cached_map_per_serializer_count config option.

Parameters:

  • value (Boolean)

    Set :check_initiate_params config option

Returns:

  • (Boolean)

    New :max_cached_map_per_serializer_count config option

Raises:



81
82
83
84
# File 'lib/serega/config.rb', line 81

def max_cached_map_per_serializer_count=(value)
  raise SeregaError, "Must have Integer value, #{value.inspect} provided" unless value.is_a?(Integer)
  opts[:max_cached_map_per_serializer_count] = value
end

#pluginsArray

Returns Used plugins.

Returns:

  • (Array)

    Used plugins



41
42
43
# File 'lib/serega/config.rb', line 41

def plugins
  opts.fetch(:plugins)
end

#serialize_keysArray<Symbol>

Returns Allowed options keys for serialization.

Returns:

  • (Array<Symbol>)

    Allowed options keys for serialization



56
57
58
# File 'lib/serega/config.rb', line 56

def serialize_keys
  opts.fetch(:serialize_keys)
end

#to_json#call

Returns Callable that used to construct JSON.

Returns:

  • (#call)

    Callable that used to construct JSON



87
88
89
# File 'lib/serega/config.rb', line 87

def to_json
  opts.fetch(:to_json)
end

#to_json=(value) ⇒ #call

Returns Provided callable object.

Parameters:

  • value (#call)

    Callable that used to construct JSON

Returns:

  • (#call)

    Provided callable object



93
94
95
# File 'lib/serega/config.rb', line 93

def to_json=(value)
  opts[:to_json] = value
end