serega 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/serega/attribute.rb +17 -4
  4. data/lib/serega/config.rb +5 -5
  5. data/lib/serega/convert.rb +7 -7
  6. data/lib/serega/convert_item.rb +4 -4
  7. data/lib/serega/helpers/serializer_class_helper.rb +1 -1
  8. data/lib/serega/map.rb +2 -2
  9. data/lib/serega/plugins/activerecord_preloads/activerecord_preloads.rb +3 -3
  10. data/lib/serega/plugins/activerecord_preloads/lib/preloader.rb +2 -2
  11. data/lib/serega/plugins/context_metadata/context_metadata.rb +4 -4
  12. data/lib/serega/plugins/formatters/formatters.rb +2 -2
  13. data/lib/serega/plugins/hide_nil/hide_nil.rb +6 -6
  14. data/lib/serega/plugins/metadata/meta_attribute.rb +4 -4
  15. data/lib/serega/plugins/metadata/metadata.rb +3 -3
  16. data/lib/serega/plugins/metadata/validations/check_block.rb +4 -4
  17. data/lib/serega/plugins/metadata/validations/check_opt_hide_empty.rb +3 -3
  18. data/lib/serega/plugins/metadata/validations/check_opt_hide_nil.rb +3 -3
  19. data/lib/serega/plugins/metadata/validations/check_opts.rb +3 -3
  20. data/lib/serega/plugins/metadata/validations/check_path.rb +3 -3
  21. data/lib/serega/plugins/preloads/lib/enum_deep_freeze.rb +1 -1
  22. data/lib/serega/plugins/preloads/lib/format_user_preloads.rb +1 -1
  23. data/lib/serega/plugins/preloads/lib/main_preload_path.rb +1 -1
  24. data/lib/serega/plugins/preloads/lib/preloads_constructor.rb +2 -2
  25. data/lib/serega/plugins/preloads/preloads.rb +7 -2
  26. data/lib/serega/plugins/preloads/validations/check_opt_preload.rb +17 -0
  27. data/lib/serega/plugins/preloads/validations/check_opt_preload_path.rb +4 -4
  28. data/lib/serega/plugins/presenter/presenter.rb +6 -6
  29. data/lib/serega/plugins/root/root.rb +3 -3
  30. data/lib/serega/plugins/string_modifiers/parse_string_modifiers.rb +1 -1
  31. data/lib/serega/plugins/string_modifiers/string_modifiers.rb +1 -1
  32. data/lib/serega/plugins/validate_modifiers/validate.rb +2 -2
  33. data/lib/serega/plugins/validate_modifiers/validate_modifiers.rb +1 -1
  34. data/lib/serega/plugins.rb +7 -7
  35. data/lib/serega/utils/as_json.rb +1 -1
  36. data/lib/serega/utils/enum_deep_dup.rb +1 -1
  37. data/lib/serega/utils/to_hash.rb +2 -2
  38. data/lib/serega/utils/to_json.rb +1 -1
  39. data/lib/serega/validations/attribute/check_block.rb +3 -3
  40. data/lib/serega/validations/attribute/check_name.rb +3 -3
  41. data/lib/serega/validations/attribute/check_opt_const.rb +5 -5
  42. data/lib/serega/validations/attribute/check_opt_delegate.rb +57 -0
  43. data/lib/serega/validations/attribute/check_opt_hide.rb +3 -3
  44. data/lib/serega/validations/attribute/check_opt_key.rb +6 -6
  45. data/lib/serega/validations/attribute/check_opt_many.rb +3 -3
  46. data/lib/serega/validations/attribute/check_opt_serializer.rb +3 -3
  47. data/lib/serega/validations/attribute/check_opt_value.rb +7 -7
  48. data/lib/serega/validations/check_attribute_params.rb +4 -3
  49. data/lib/serega/validations/check_initiate_params.rb +3 -3
  50. data/lib/serega/validations/check_serialize_params.rb +5 -5
  51. data/lib/serega/validations/utils/check_allowed_keys.rb +3 -3
  52. data/lib/serega/validations/utils/check_opt_is_bool.rb +3 -3
  53. data/lib/serega/validations/utils/check_opt_is_hash.rb +3 -3
  54. data/lib/serega/validations/utils/check_opt_is_string_or_symbol.rb +3 -3
  55. data/lib/serega.rb +30 -43
  56. metadata +4 -2
@@ -4,7 +4,7 @@ require "delegate"
4
4
  require "forwardable"
5
5
 
6
6
  class Serega
7
- module Plugins
7
+ module SeregaPlugins
8
8
  #
9
9
  # Plugin Presenter adds possibility to use declare Presenter for your objects inside serializer
10
10
  #
@@ -35,7 +35,7 @@ class Serega
35
35
  #
36
36
  def self.load_plugin(serializer_class, **_opts)
37
37
  serializer_class.extend(ClassMethods)
38
- serializer_class::ConvertItem.extend(ConvertItemClassMethods)
38
+ serializer_class::SeregaConvertItem.extend(SeregaConvertItemClassMethods)
39
39
  end
40
40
 
41
41
  #
@@ -69,7 +69,7 @@ class Serega
69
69
  end
70
70
  end
71
71
 
72
- extend Helpers::SerializerClassHelper
72
+ extend SeregaHelpers::SerializerClassHelper
73
73
  extend Forwardable
74
74
  include InstanceMethods
75
75
  end
@@ -85,7 +85,7 @@ class Serega
85
85
  end
86
86
 
87
87
  # Overrides {Serega::ClassMethods#attribute} method, additionally adds method
88
- # to Presenter to not hit {Serega::Plugins::Presenter::Presenter#method_missing}
88
+ # to Presenter to not hit {Serega::SeregaPlugins::Presenter::Presenter#method_missing}
89
89
  # @see Serega::ClassMethods#attribute
90
90
  def attribute(_name, **_opts, &_block)
91
91
  super.tap do |attribute|
@@ -94,8 +94,8 @@ class Serega
94
94
  end
95
95
  end
96
96
 
97
- # Includes methods to override ConvertItem class
98
- module ConvertItemClassMethods
97
+ # Includes methods to override SeregaConvertItem class
98
+ module SeregaConvertItemClassMethods
99
99
  #
100
100
  # Replaces serialized object with Presenter.new(object)
101
101
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Plugins
4
+ module SeregaPlugins
5
5
  module Root
6
6
  # @return [Symbol] Default response root key
7
7
  ROOT_DEFAULT = :data
@@ -12,7 +12,7 @@ class Serega
12
12
 
13
13
  def self.load_plugin(serializer_class, **_opts)
14
14
  serializer_class.extend(ClassMethods)
15
- serializer_class::Convert.include(ConvertInstanceMethods)
15
+ serializer_class::SeregaConvert.include(SeregaConvertInstanceMethods)
16
16
  end
17
17
 
18
18
  def self.after_load_plugin(serializer_class, **opts)
@@ -41,7 +41,7 @@ class Serega
41
41
  end
42
42
  end
43
43
 
44
- module ConvertInstanceMethods
44
+ module SeregaConvertInstanceMethods
45
45
  def to_h
46
46
  hash = super
47
47
  root = build_root(opts)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Plugins
4
+ module SeregaPlugins
5
5
  module StringModifiers
6
6
  class ParseStringModifiers
7
7
  COMMA = ","
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Plugins
4
+ module SeregaPlugins
5
5
  module StringModifiers
6
6
  def self.plugin_name
7
7
  :string_modifiers
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- class AttributeNotExist < Error
4
+ class AttributeNotExist < SeregaError
5
5
  end
6
6
 
7
- module Plugins
7
+ module SeregaPlugins
8
8
  module ValidateModifiers
9
9
  class Validate
10
10
  class << self
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Plugins
4
+ module SeregaPlugins
5
5
  module ValidateModifiers
6
6
  def self.plugin_name
7
7
  :validate_modifiers
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Serega
4
4
  # Module in which all Serega plugins should be stored
5
- module Plugins
5
+ module SeregaPlugins
6
6
  @plugins = {}
7
7
 
8
8
  class << self
@@ -10,7 +10,7 @@ class Serega
10
10
  # Registers given plugin to be able to load it using symbol name.
11
11
  #
12
12
  # @example Register plugin
13
- # Serega::Plugins.register_plugin(:plugin_name, PluginModule)
13
+ # Serega::SeregaPlugins.register_plugin(:plugin_name, PluginModule)
14
14
  def register_plugin(name, mod)
15
15
  @plugins[name] = mod
16
16
  end
@@ -20,13 +20,13 @@ class Serega
20
20
  #
21
21
  # @param name [Symbol, Module] plugin name or plugin itself
22
22
  #
23
- # @raise [Error] Raises Error when plugin was not found
23
+ # @raise [SeregaError] Raises SeregaError when plugin was not found
24
24
  #
25
25
  # @example Find plugin when providing name
26
- # Serega::Plugins.find_plugin(:presenter) # => Serega::Plugins::Presenter
26
+ # Serega::SeregaPlugins.find_plugin(:presenter) # => Serega::SeregaPlugins::Presenter
27
27
  #
28
28
  # @example Find plugin when providing plugin itself
29
- # Serega::Plugins.find_plugin(Presenter) # => Presenter
29
+ # Serega::SeregaPlugins.find_plugin(Presenter) # => Presenter
30
30
  #
31
31
  # @return [Class<Module>] Plugin core module
32
32
  #
@@ -36,7 +36,7 @@ class Serega
36
36
 
37
37
  require_plugin(name)
38
38
 
39
- @plugins[name] || raise(Error, "Plugin '#{name}' did not register itself correctly")
39
+ @plugins[name] || raise(SeregaError, "Plugin '#{name}' did not register itself correctly")
40
40
  end
41
41
 
42
42
  private
@@ -44,7 +44,7 @@ class Serega
44
44
  def require_plugin(name)
45
45
  require "serega/plugins/#{name}/#{name}"
46
46
  rescue LoadError
47
- raise Error, "Plugin '#{name}' does not exist"
47
+ raise SeregaError, "Plugin '#{name}' does not exist"
48
48
  end
49
49
  end
50
50
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Utils
4
+ module SeregaUtils
5
5
  class AsJSON
6
6
  DOUBLE_QUOTE = '"'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Utils
4
+ module SeregaUtils
5
5
  # Duplicates nested hashes and arrays
6
6
  class EnumDeepDup
7
7
  DUP = {
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Utils
4
+ module SeregaUtils
5
5
  class ToHash
6
6
  module ClassMethods
7
7
  def call(value)
@@ -11,7 +11,7 @@ class Serega
11
11
  when NilClass, FalseClass then nil_to_hash(value)
12
12
  when String then string_to_hash(value)
13
13
  when Symbol then symbol_to_hash(value)
14
- else raise Error, "Cant convert #{value.class} class object to hash"
14
+ else raise SeregaError, "Cant convert #{value.class} class object to hash"
15
15
  end
16
16
  end
17
17
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Utils
4
+ module SeregaUtils
5
5
  class ToJSON
6
6
  class << self
7
7
  def call(data)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckBlock
7
7
  class << self
@@ -22,7 +22,7 @@ class Serega
22
22
  # @param opts [Proc] Attribute opts, we will check :value option
23
23
  # @param block [Proc] Block that returns serialized attribute value
24
24
  #
25
- # @raise [Error] Error that block has invalid arguments
25
+ # @raise [SeregaError] SeregaError that block has invalid arguments
26
26
  #
27
27
  # @return [void]
28
28
  #
@@ -38,7 +38,7 @@ class Serega
38
38
  params = block.parameters
39
39
  return if (params.count <= 2) && params.all? { |par| par[0] == :opt }
40
40
 
41
- raise Error, block_error
41
+ raise SeregaError, block_error
42
42
  end
43
43
 
44
44
  def block_error
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckName
7
7
  FORMAT_ONE_CHAR = /\A[a-zA-Z0-9]\z/
@@ -17,7 +17,7 @@ class Serega
17
17
  #
18
18
  # @param name [String, Symbol] Attribute name
19
19
  #
20
- # @raise [Error] when name has invalid format
20
+ # @raise [SeregaError] when name has invalid format
21
21
  # @return [void]
22
22
  #
23
23
  def call(name)
@@ -32,7 +32,7 @@ class Serega
32
32
 
33
33
  return if valid
34
34
 
35
- raise Error, message(name)
35
+ raise SeregaError, message(name)
36
36
  end
37
37
 
38
38
  private
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckOptConst
7
7
  #
@@ -9,7 +9,7 @@ class Serega
9
9
  #
10
10
  # @param opts [Hash] Attribute options
11
11
  #
12
- # @raise [Error] Attribute validation error
12
+ # @raise [SeregaError] Attribute validation error
13
13
  #
14
14
  # @return [void]
15
15
  #
@@ -23,9 +23,9 @@ class Serega
23
23
  private
24
24
 
25
25
  def check_usage_with_other_params(opts, block)
26
- raise Error, "Option :const can not be used together with option :key" if opts.key?(:key)
27
- raise Error, "Option :const can not be used together with option :value" if opts.key?(:value)
28
- raise Error, "Option :const can not be used together with block" if block
26
+ raise SeregaError, "Option :const can not be used together with option :key" if opts.key?(:key)
27
+ raise SeregaError, "Option :const can not be used together with option :value" if opts.key?(:value)
28
+ raise SeregaError, "Option :const can not be used together with block" if block
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Serega
4
+ module SeregaValidations
5
+ module Attribute
6
+ class CheckOptDelegate
7
+ #
8
+ # Checks attribute :delegate option
9
+ # It must have :to option and can have :optional allow_nil option
10
+ #
11
+ # @param opts [Hash] Attribute options
12
+ #
13
+ # @raise [SeregaError] Attribute validation error
14
+ #
15
+ # @return [void]
16
+ #
17
+ class << self
18
+ def call(opts, block = nil)
19
+ return unless opts.key?(:delegate)
20
+
21
+ check_opt_delegate(opts)
22
+ check_usage_with_other_params(opts, block)
23
+ end
24
+
25
+ private
26
+
27
+ def check_opt_delegate(opts)
28
+ SeregaUtils::CheckOptIsHash.call(opts, :delegate)
29
+
30
+ delegate_opts = opts[:delegate]
31
+ check_opt_delegate_to(delegate_opts)
32
+ check_opt_delegate_allow_nil(delegate_opts)
33
+ end
34
+
35
+ def check_opt_delegate_to(delegate_opts)
36
+ to_exist = delegate_opts.key?(:to)
37
+ raise SeregaError, "Option :delegate must have a :to option" unless to_exist
38
+
39
+ SeregaUtils::CheckOptIsStringOrSymbol.call(delegate_opts, :to)
40
+ end
41
+
42
+ def check_opt_delegate_allow_nil(delegate_opts)
43
+ return unless delegate_opts.key?(:allow_nil)
44
+
45
+ SeregaUtils::CheckOptIsBool.call(delegate_opts, :allow_nil)
46
+ end
47
+
48
+ def check_usage_with_other_params(opts, block)
49
+ raise SeregaError, "Option :delegate can not be used together with option :const" if opts.key?(:const)
50
+ raise SeregaError, "Option :delegate can not be used together with option :value" if opts.key?(:value)
51
+ raise SeregaError, "Option :delegate can not be used together with block" if block
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckOptHide
7
7
  #
@@ -9,12 +9,12 @@ class Serega
9
9
  #
10
10
  # @param opts [Hash] Attribute options
11
11
  #
12
- # @raise [Error] Error that option has invalid value
12
+ # @raise [SeregaError] SeregaError that option has invalid value
13
13
  #
14
14
  # @return [void]
15
15
  #
16
16
  def self.call(opts)
17
- Utils::CheckOptIsBool.call(opts, :hide)
17
+ SeregaUtils::CheckOptIsBool.call(opts, :hide)
18
18
  end
19
19
  end
20
20
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckOptKey
7
7
  #
@@ -9,7 +9,7 @@ class Serega
9
9
  #
10
10
  # @param opts [Hash] Attribute options
11
11
  #
12
- # @raise [Error] Error that option has invalid value
12
+ # @raise [SeregaError] SeregaError that option has invalid value
13
13
  #
14
14
  # @return [void]
15
15
  #
@@ -18,15 +18,15 @@ class Serega
18
18
  return unless opts.key?(:key)
19
19
 
20
20
  check_usage_with_other_params(opts, block)
21
- Utils::CheckOptIsStringOrSymbol.call(opts, :key)
21
+ SeregaUtils::CheckOptIsStringOrSymbol.call(opts, :key)
22
22
  end
23
23
 
24
24
  private
25
25
 
26
26
  def check_usage_with_other_params(opts, block)
27
- raise Error, "Option :key can not be used together with option :const" if opts.key?(:const)
28
- raise Error, "Option :key can not be used together with option :value" if opts.key?(:value)
29
- raise Error, "Option :key can not be used together with block" if block
27
+ raise SeregaError, "Option :key can not be used together with option :const" if opts.key?(:const)
28
+ raise SeregaError, "Option :key can not be used together with option :value" if opts.key?(:value)
29
+ raise SeregaError, "Option :key can not be used together with block" if block
30
30
  end
31
31
  end
32
32
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckOptMany
7
7
  #
@@ -9,12 +9,12 @@ class Serega
9
9
  #
10
10
  # @param opts [Hash] Attribute options
11
11
  #
12
- # @raise [Error] Error that option has invalid value
12
+ # @raise [SeregaError] SeregaError that option has invalid value
13
13
  #
14
14
  # @return [void]
15
15
  #
16
16
  def self.call(opts)
17
- Utils::CheckOptIsBool.call(opts, :many)
17
+ SeregaUtils::CheckOptIsBool.call(opts, :many)
18
18
  end
19
19
  end
20
20
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckOptSerializer
7
7
  class << self
@@ -10,7 +10,7 @@ class Serega
10
10
  #
11
11
  # @param opts [Hash] Attribute options
12
12
  #
13
- # @raise [Error] Error that option has invalid value
13
+ # @raise [SeregaError] SeregaError that option has invalid value
14
14
  #
15
15
  # @return [void]
16
16
  #
@@ -20,7 +20,7 @@ class Serega
20
20
  value = opts[:serializer]
21
21
  return if valid_serializer?(value)
22
22
 
23
- raise Error, "Invalid option :serializer => #{value.inspect}." \
23
+ raise SeregaError, "Invalid option :serializer => #{value.inspect}." \
24
24
  " Can be a Serega subclass, a String or a Proc without arguments"
25
25
  end
26
26
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  module Attribute
6
6
  class CheckOptValue
7
7
  #
@@ -9,7 +9,7 @@ class Serega
9
9
  #
10
10
  # @param opts [Hash] Attribute options
11
11
  #
12
- # @raise [Error] Error that option has invalid value
12
+ # @raise [SeregaError] SeregaError that option has invalid value
13
13
  #
14
14
  # @return [void]
15
15
  #
@@ -24,13 +24,13 @@ class Serega
24
24
  private
25
25
 
26
26
  def check_usage_with_other_params(opts, block)
27
- raise Error, "Option :value can not be used together with option :key" if opts.key?(:key)
28
- raise Error, "Option :value can not be used together with option :const" if opts.key?(:const)
29
- raise Error, "Option :value can not be used together with block" if block
27
+ raise SeregaError, "Option :value can not be used together with option :key" if opts.key?(:key)
28
+ raise SeregaError, "Option :value can not be used together with option :const" if opts.key?(:const)
29
+ raise SeregaError, "Option :value can not be used together with block" if block
30
30
  end
31
31
 
32
32
  def check_proc(value)
33
- raise Error, value_error unless value.is_a?(Proc)
33
+ raise SeregaError, value_error unless value.is_a?(Proc)
34
34
 
35
35
  params = value.parameters
36
36
 
@@ -40,7 +40,7 @@ class Serega
40
40
  return
41
41
  end
42
42
 
43
- raise Error, value_error
43
+ raise SeregaError, value_error
44
44
  end
45
45
 
46
46
  def value_error
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  class CheckAttributeParams
6
6
  module InstanceMethods
7
7
  attr_reader :name, :opts, :block
@@ -25,9 +25,10 @@ class Serega
25
25
  end
26
26
 
27
27
  def check_opts
28
- Utils::CheckAllowedKeys.call(opts, allowed_opts_keys)
28
+ SeregaUtils::CheckAllowedKeys.call(opts, allowed_opts_keys)
29
29
 
30
30
  Attribute::CheckOptConst.call(opts, block)
31
+ Attribute::CheckOptDelegate.call(opts, block)
31
32
  Attribute::CheckOptHide.call(opts)
32
33
  Attribute::CheckOptKey.call(opts, block)
33
34
  Attribute::CheckOptMany.call(opts)
@@ -45,7 +46,7 @@ class Serega
45
46
  end
46
47
 
47
48
  include InstanceMethods
48
- extend Serega::Helpers::SerializerClassHelper
49
+ extend Serega::SeregaHelpers::SerializerClassHelper
49
50
  end
50
51
  end
51
52
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  class CheckInitiateParams
6
6
  module ClassMethods
7
7
  def call(opts)
@@ -11,7 +11,7 @@ class Serega
11
11
  private
12
12
 
13
13
  def check_opts(opts)
14
- Utils::CheckAllowedKeys.call(opts, allowed_opts_keys)
14
+ SeregaUtils::CheckAllowedKeys.call(opts, allowed_opts_keys)
15
15
  end
16
16
 
17
17
  def allowed_opts_keys
@@ -20,7 +20,7 @@ class Serega
20
20
  end
21
21
 
22
22
  extend ClassMethods
23
- extend Serega::Helpers::SerializerClassHelper
23
+ extend Serega::SeregaHelpers::SerializerClassHelper
24
24
  end
25
25
  end
26
26
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
4
+ module SeregaValidations
5
5
  class CheckSerializeParams
6
6
  module ClassMethods
7
7
  def call(opts)
@@ -11,10 +11,10 @@ class Serega
11
11
  private
12
12
 
13
13
  def check_opts(opts)
14
- Utils::CheckAllowedKeys.call(opts, allowed_opts_keys)
14
+ SeregaUtils::CheckAllowedKeys.call(opts, allowed_opts_keys)
15
15
 
16
- Utils::CheckOptIsHash.call(opts, :context)
17
- Utils::CheckOptIsBool.call(opts, :many)
16
+ SeregaUtils::CheckOptIsHash.call(opts, :context)
17
+ SeregaUtils::CheckOptIsBool.call(opts, :many)
18
18
  end
19
19
 
20
20
  def allowed_opts_keys
@@ -23,7 +23,7 @@ class Serega
23
23
  end
24
24
 
25
25
  extend ClassMethods
26
- extend Serega::Helpers::SerializerClassHelper
26
+ extend Serega::SeregaHelpers::SerializerClassHelper
27
27
  end
28
28
  end
29
29
  end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
5
- module Utils
4
+ module SeregaValidations
5
+ module SeregaUtils
6
6
  class CheckAllowedKeys
7
7
  def self.call(opts, allowed_keys)
8
8
  opts.each_key do |key|
9
9
  next if allowed_keys.include?(key)
10
10
 
11
- raise Error, "Invalid option #{key.inspect}. Allowed options are: #{allowed_keys.map(&:inspect).join(", ")}"
11
+ raise SeregaError, "Invalid option #{key.inspect}. Allowed options are: #{allowed_keys.map(&:inspect).join(", ")}"
12
12
  end
13
13
  end
14
14
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
5
- module Utils
4
+ module SeregaValidations
5
+ module SeregaUtils
6
6
  class CheckOptIsBool
7
7
  def self.call(opts, key)
8
8
  return unless opts.key?(key)
@@ -10,7 +10,7 @@ class Serega
10
10
  value = opts[key]
11
11
  return if value.equal?(true) || value.equal?(false)
12
12
 
13
- raise Error, "Invalid option #{key.inspect} => #{value.inspect}. Must have a boolean value"
13
+ raise SeregaError, "Invalid option #{key.inspect} => #{value.inspect}. Must have a boolean value"
14
14
  end
15
15
  end
16
16
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Serega
4
- module Validations
5
- module Utils
4
+ module SeregaValidations
5
+ module SeregaUtils
6
6
  class CheckOptIsHash
7
7
  def self.call(opts, key)
8
8
  return unless opts.key?(key)
@@ -10,7 +10,7 @@ class Serega
10
10
  value = opts[key]
11
11
  return if value.is_a?(Hash)
12
12
 
13
- raise Error, "Invalid option #{key.inspect} => #{value.inspect}. Must have a Hash value"
13
+ raise SeregaError, "Invalid option #{key.inspect} => #{value.inspect}. Must have a Hash value"
14
14
  end
15
15
  end
16
16
  end