Module: Serega::SeregaConfig::SeregaConfigInstanceMethods
- Included in:
- Serega::SeregaConfig
- Defined in:
- lib/serega/config.rb
Overview
SeregaConfig Instance methods
Instance Attribute Summary collapse
-
#opts ⇒ Hash
readonly
Shows current config as Hash.
Instance Method Summary collapse
-
#attribute_keys ⇒ Array<Symbol>
Returns options names allowed in ‘Serega.attribute` method.
-
#check_attribute_name ⇒ Object
Returns whether attributes names check is disabled.
-
#check_attribute_name=(value) ⇒ Boolean
Sets :check_attribute_name config option.
-
#check_initiate_params ⇒ Boolean
Returns :check_initiate_params config option.
-
#check_initiate_params=(value) ⇒ Boolean
Sets :check_initiate_params config option.
-
#from_json ⇒ #call
Returns current ‘from_json` adapter.
-
#from_json=(value) ⇒ #call
Sets current ‘from_json` adapter.
-
#initialize(opts = nil) ⇒ Object
Initializes new config instance.
-
#initiate_keys ⇒ Array<Symbol>
Returns options names allowed in ‘Serega#new` method.
-
#max_cached_map_per_serializer_count ⇒ Boolean
Returns :max_cached_map_per_serializer_count config option.
-
#max_cached_map_per_serializer_count=(value) ⇒ Boolean
Sets :max_cached_map_per_serializer_count config option.
-
#plugins ⇒ Array
Shows used plugins.
-
#serialize_keys ⇒ Array<Symbol>
Returns options names allowed in ‘to_h, to_json, as_json` methods.
-
#to_json ⇒ #call
Returns current ‘to_json` adapter.
-
#to_json=(value) ⇒ #call
Sets current ‘to_json` adapter.
Instance Attribute Details
#opts ⇒ Hash (readonly)
Shows current config as Hash
35 36 37 |
# File 'lib/serega/config.rb', line 35 def opts @opts end |
Instance Method Details
#attribute_keys ⇒ Array<Symbol>
Returns options names allowed in ‘Serega.attribute` method
64 65 66 |
# File 'lib/serega/config.rb', line 64 def attribute_keys opts.fetch(:attribute_keys) end |
#check_attribute_name ⇒ Object
Returns whether attributes names check is disabled
107 108 109 |
# File 'lib/serega/config.rb', line 107 def check_attribute_name opts.fetch(:check_attribute_name) end |
#check_attribute_name=(value) ⇒ Boolean
Sets :check_attribute_name config option
116 117 118 119 |
# File 'lib/serega/config.rb', line 116 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_params ⇒ Boolean
Returns :check_initiate_params config option
76 77 78 |
# File 'lib/serega/config.rb', line 76 def check_initiate_params opts.fetch(:check_initiate_params) end |
#check_initiate_params=(value) ⇒ Boolean
Sets :check_initiate_params config option
85 86 87 88 |
# File 'lib/serega/config.rb', line 85 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 current ‘from_json` adapter
136 137 138 |
# File 'lib/serega/config.rb', line 136 def from_json opts.fetch(:from_json) end |
#from_json=(value) ⇒ #call
Sets current ‘from_json` adapter
143 144 145 |
# File 'lib/serega/config.rb', line 143 def from_json=(value) opts[:from_json] = value end |
#initialize(opts = nil) ⇒ Object
Initializes new config instance.
42 43 44 45 |
# File 'lib/serega/config.rb', line 42 def initialize(opts = nil) opts ||= DEFAULTS @opts = SeregaUtils::EnumDeepDup.call(opts) end |
#initiate_keys ⇒ Array<Symbol>
Returns options names allowed in ‘Serega#new` method
58 59 60 |
# File 'lib/serega/config.rb', line 58 def initiate_keys opts.fetch(:initiate_keys) end |
#max_cached_map_per_serializer_count ⇒ Boolean
Returns :max_cached_map_per_serializer_count config option
92 93 94 |
# File 'lib/serega/config.rb', line 92 def max_cached_map_per_serializer_count opts.fetch(:max_cached_map_per_serializer_count) end |
#max_cached_map_per_serializer_count=(value) ⇒ Boolean
Sets :max_cached_map_per_serializer_count config option
101 102 103 104 |
# File 'lib/serega/config.rb', line 101 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 |
#plugins ⇒ Array
Shows used plugins
52 53 54 |
# File 'lib/serega/config.rb', line 52 def plugins opts.fetch(:plugins) end |
#serialize_keys ⇒ Array<Symbol>
Returns options names allowed in ‘to_h, to_json, as_json` methods
70 71 72 |
# File 'lib/serega/config.rb', line 70 def serialize_keys opts.fetch(:serialize_keys) end |
#to_json ⇒ #call
Returns current ‘to_json` adapter
123 124 125 |
# File 'lib/serega/config.rb', line 123 def to_json opts.fetch(:to_json) end |
#to_json=(value) ⇒ #call
Sets current ‘to_json` adapter
130 131 132 |
# File 'lib/serega/config.rb', line 130 def to_json=(value) opts[:to_json] = value end |