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)

Shows current config as Hash

Returns:

  • (Hash)

    config options



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

def opts
  @opts
end

Instance Method Details

#attribute_keysArray<Symbol>

Returns options names allowed in ‘Serega.attribute` method

Returns:

  • (Array<Symbol>)

    Allowed options keys for attribute initialization



63
64
65
# File 'lib/serega/config.rb', line 63

def attribute_keys
  opts.fetch(:attribute_keys)
end

#check_attribute_nameObject

Returns whether attributes names check is disabled



122
123
124
# File 'lib/serega/config.rb', line 122

def check_attribute_name
  opts.fetch(:check_attribute_name)
end

#check_attribute_name=(value) ⇒ Boolean

Sets :check_attribute_name config option

Parameters:

  • value (Boolean)

    Set :check_attribute_name config option

Returns:

  • (Boolean)

    New :check_attribute_name config option

Raises:



131
132
133
134
# File 'lib/serega/config.rb', line 131

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

#check_initiate_paramsBoolean

Returns :check_initiate_params config option

Returns:

  • (Boolean)

    Current :check_initiate_params config option



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

def check_initiate_params
  opts.fetch(:check_initiate_params)
end

#check_initiate_params=(value) ⇒ Boolean

Sets :check_initiate_params config option

Parameters:

  • value (Boolean)

    Set :check_initiate_params config option

Returns:

  • (Boolean)

    :check_initiate_params config option

Raises:



84
85
86
87
# File 'lib/serega/config.rb', line 84

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

#delegate_default_allow_nilBoolean

Returns :delegate_default_allow_nil config option

Returns:

  • (Boolean)

    Current :delegate_default_allow_nil config option



91
92
93
# File 'lib/serega/config.rb', line 91

def delegate_default_allow_nil
  opts.fetch(:delegate_default_allow_nil)
end

#delegate_default_allow_nil=(value) ⇒ Boolean

Sets :delegate_default_allow_nil config option

Parameters:

  • value (Boolean)

    Set :delegate_default_allow_nil config option

Returns:

  • (Boolean)

    :delegate_default_allow_nil config option

Raises:



100
101
102
103
# File 'lib/serega/config.rb', line 100

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

#from_json#call

Returns current ‘from_json` adapter

Returns:

  • (#call)

    Callable that used to parse JSON



151
152
153
# File 'lib/serega/config.rb', line 151

def from_json
  opts.fetch(:from_json)
end

#from_json=(value) ⇒ #call

Sets current ‘from_json` adapter

Parameters:

  • value (#call)

    Callable that used to parse JSON

Returns:

  • (#call)

    Provided callable object



158
159
160
# File 'lib/serega/config.rb', line 158

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



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

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

#initiate_keysArray<Symbol>

Returns options names allowed in ‘Serega#new` method

Returns:

  • (Array<Symbol>)

    allowed options keys



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

def initiate_keys
  opts.fetch(:initiate_keys)
end

#max_cached_plans_per_serializer_countBoolean

Returns :max_cached_plans_per_serializer_count config option

Returns:

  • (Boolean)

    Current :max_cached_plans_per_serializer_count config option



107
108
109
# File 'lib/serega/config.rb', line 107

def max_cached_plans_per_serializer_count
  opts.fetch(:max_cached_plans_per_serializer_count)
end

#max_cached_plans_per_serializer_count=(value) ⇒ Boolean

Sets :max_cached_plans_per_serializer_count config option

Parameters:

  • value (Boolean)

    Set :check_initiate_params config option

Returns:

  • (Boolean)

    New :max_cached_plans_per_serializer_count config option

Raises:



116
117
118
119
# File 'lib/serega/config.rb', line 116

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

#pluginsArray

Shows used plugins

Returns:

  • (Array)

    Used plugins



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

def plugins
  opts.fetch(:plugins)
end

#serialize_keysArray<Symbol>

Returns options names allowed in ‘to_h, to_json, as_json` methods

Returns:

  • (Array<Symbol>)

    Allowed options keys for serialization



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

def serialize_keys
  opts.fetch(:serialize_keys)
end

#to_json#call

Returns current ‘to_json` adapter

Returns:

  • (#call)

    Callable that used to construct JSON



138
139
140
# File 'lib/serega/config.rb', line 138

def to_json
  opts.fetch(:to_json)
end

#to_json=(value) ⇒ #call

Sets current ‘to_json` adapter

Parameters:

  • value (#call)

    Callable that used to construct JSON

Returns:

  • (#call)

    Provided callable object



145
146
147
# File 'lib/serega/config.rb', line 145

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