eco-helpers 0.9.2 → 0.9.3

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/lib/eco/api.rb +1 -0
  3. data/lib/eco/api/common.rb +1 -0
  4. data/lib/eco/api/common/class_helpers.rb +33 -0
  5. data/lib/eco/api/common/people.rb +1 -0
  6. data/lib/eco/api/common/people/person_attribute_parser.rb +52 -0
  7. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +2 -2
  8. data/lib/eco/api/common/people/person_parser.rb +16 -10
  9. data/lib/eco/api/common/version_patches.rb +2 -3
  10. data/lib/eco/api/common/version_patches/ecoportal_api.rb +4 -0
  11. data/lib/eco/api/common/version_patches/{base_model.rb → ecoportal_api/base_model.rb} +0 -0
  12. data/lib/eco/api/common/version_patches/{external_person.rb → ecoportal_api/external_person.rb} +0 -0
  13. data/lib/eco/api/common/version_patches/{internal_person.rb → ecoportal_api/internal_person.rb} +0 -0
  14. data/lib/eco/api/common/version_patches/hash.rb +2 -0
  15. data/lib/eco/api/common/version_patches/hash/deep_merge.rb +34 -0
  16. data/lib/eco/api/error.rb +133 -0
  17. data/lib/eco/api/error/handler.rb +19 -0
  18. data/lib/eco/api/error/handlers.rb +22 -0
  19. data/lib/eco/api/organization/people.rb +11 -11
  20. data/lib/eco/api/organization/policy_groups.rb +8 -0
  21. data/lib/eco/api/policies.rb +26 -3
  22. data/lib/eco/api/policies/policy.rb +4 -5
  23. data/lib/eco/api/session.rb +27 -18
  24. data/lib/eco/api/session/batch.rb +12 -6
  25. data/lib/eco/api/session/batch/errors.rb +134 -0
  26. data/lib/eco/api/session/batch/job.rb +213 -0
  27. data/lib/eco/api/session/batch/jobs.rb +72 -0
  28. data/lib/eco/api/session/batch/jobs_groups.rb +85 -0
  29. data/lib/eco/api/session/batch/status.rb +133 -0
  30. data/lib/eco/api/session/config.rb +36 -14
  31. data/lib/eco/api/session/config/base_config.rb +2 -0
  32. data/lib/eco/api/session/config/people.rb +8 -0
  33. data/lib/eco/api/session/config/post_launch.rb +58 -0
  34. data/lib/eco/api/session/config/workflow.rb +189 -0
  35. data/lib/eco/api/session/task.rb +49 -6
  36. data/lib/eco/api/usecases.rb +137 -2
  37. data/lib/eco/api/usecases/base_case.rb +20 -8
  38. data/lib/eco/api/usecases/base_io.rb +97 -0
  39. data/lib/eco/api/usecases/default_case.rb +19 -0
  40. data/lib/eco/api/usecases/default_cases.rb +2 -2
  41. data/lib/eco/api/usecases/default_cases/change_email_case.rb +2 -2
  42. data/lib/eco/api/usecases/default_cases/create_case.rb +2 -2
  43. data/lib/eco/api/usecases/default_cases/create_details_case.rb +2 -2
  44. data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +2 -2
  45. data/lib/eco/api/usecases/default_cases/delete_case.rb +2 -2
  46. data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +2 -2
  47. data/lib/eco/api/usecases/default_cases/hris_case.rb +2 -2
  48. data/lib/eco/api/usecases/default_cases/new_email_case.rb +2 -2
  49. data/lib/eco/api/usecases/default_cases/new_id_case.rb +2 -2
  50. data/lib/eco/api/usecases/default_cases/recover_db_case.rb +11 -8
  51. data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +2 -2
  52. data/lib/eco/api/usecases/default_cases/reinvite_case.rb +2 -2
  53. data/lib/eco/api/usecases/default_cases/remove_account_case.rb +2 -2
  54. data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +2 -2
  55. data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +2 -2
  56. data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +2 -2
  57. data/lib/eco/api/usecases/default_cases/switch_supervisor_case.rb +2 -2
  58. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +4 -4
  59. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +3 -3
  60. data/lib/eco/api/usecases/default_cases/update_case.rb +2 -2
  61. data/lib/eco/api/usecases/default_cases/update_details_case.rb +2 -2
  62. data/lib/eco/api/usecases/default_cases/upsert_case.rb +2 -2
  63. data/lib/eco/api/usecases/use_case.rb +23 -36
  64. data/lib/eco/api/usecases/use_case_chain.rb +14 -24
  65. data/lib/eco/api/usecases/use_case_io.rb +23 -75
  66. data/lib/eco/assets.rb +11 -11
  67. data/lib/eco/cli.rb +37 -0
  68. data/lib/eco/cli/config.rb +63 -1
  69. data/lib/eco/cli/config/default.rb +15 -0
  70. data/lib/eco/cli/config/default/filters.rb +69 -0
  71. data/lib/eco/cli/config/default/input.rb +21 -0
  72. data/lib/eco/cli/config/default/options.rb +47 -0
  73. data/lib/eco/cli/config/default/people.rb +39 -0
  74. data/lib/eco/cli/config/default/usecases.rb +63 -0
  75. data/lib/eco/cli/config/default/workflow.rb +86 -0
  76. data/lib/eco/cli/config/input.rb +40 -0
  77. data/lib/eco/cli/config/options_set.rb +35 -0
  78. data/lib/eco/cli/config/people_filters.rb +38 -0
  79. data/lib/eco/cli/config/use_cases.rb +87 -0
  80. data/lib/eco/cli/scripting/args_helpers.rb +10 -4
  81. data/lib/eco/cli/scripting/argument.rb +6 -0
  82. data/lib/eco/language/models/collection.rb +1 -0
  83. data/lib/eco/version.rb +1 -1
  84. metadata +32 -12
  85. data/lib/eco/api/policies/base_policy.rb +0 -14
  86. data/lib/eco/api/policies/used_policies.rb +0 -37
  87. data/lib/eco/api/session/batch_job.rb +0 -215
  88. data/lib/eco/api/session/batch_jobs.rb +0 -62
  89. data/lib/eco/api/session/batch_status.rb +0 -205
  90. data/lib/eco/api/session/job_groups.rb +0 -75
  91. data/lib/eco/api/usecases/use_group.rb +0 -124
  92. data/lib/eco/cli/config/options.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3aec55ff6424177729ff863f6652dfe53fecd2df84111036d336e216f9df441
4
- data.tar.gz: 86faa0568a8d3bc393cbbe4db62bb367230035de12230739c68891d551ae16b7
3
+ metadata.gz: c71b81aaf2b40c4f9388fc87176a3ca7b5cd4c274a760546aaae8e98b00abea5
4
+ data.tar.gz: cfefc68eed3bfbfd1767ca222bf3c7dfca2d7ce77d94fa6cf5b0b406754ae0aa
5
5
  SHA512:
6
- metadata.gz: 49f68f024a1e129502ec505b79b945feec5f40a99dfa8c7ebb45ea9699c889efffaad23b1e0c08302032a92cc117a0fb9ecf404cb68cdf6d576deb283d63118e
7
- data.tar.gz: 64777d1d3c04e878538f70b41fd0fc67ec4a951c1d59ade2300a96174c006ff68d1a2c12c9c661b57bc75af5e71e8d690c1e8239664373b426328d4e247a674d
6
+ metadata.gz: 14234f90a41da5093e8f1af208edc9aea7f454c8f15b8a19dcbbfce63559d3e82b47de850160d3f843d30ab0fac0fc9c44bd3f60a56e056c7b8922f64624da29
7
+ data.tar.gz: 6c8d9cf5e0311591601be6e1f211c23667b5ea7902e8704edaa53eeb1d3e1123780b0bc7fee44b85d39792e2bbe7cf23c43b5a8dc815db69fc16e5e3daa9fe88
data/lib/eco/api.rb CHANGED
@@ -8,6 +8,7 @@ end
8
8
  require_relative 'api/common'
9
9
  require_relative 'api/usecases'
10
10
  require_relative 'api/policies'
11
+ require_relative 'api/error'
11
12
  require_relative 'api/organization'
12
13
  require_relative 'api/session'
13
14
  require_relative 'api/eco_faker'
@@ -6,5 +6,6 @@ module Eco
6
6
  end
7
7
 
8
8
  require_relative 'common/version_patches'
9
+ require_relative 'common/class_helpers'
9
10
  require_relative 'common/people'
10
11
  require_relative 'common/session'
@@ -0,0 +1,33 @@
1
+ module Eco
2
+ module API
3
+ module Common
4
+ module ClassHelpers
5
+
6
+ def class_resolver(name, klass)
7
+ define_singleton_method(name) { resolve_class(klass) }
8
+ define_method(name) { self.class.resolve_class(klass) }
9
+ end
10
+
11
+ def resolve_class(klass, exception: true)
12
+ @resolved ||= {}
13
+ @resolved[klass] ||=
14
+ case klass
15
+ when Class
16
+ klass
17
+ when String
18
+ begin
19
+ Kernel.const_get(klass)
20
+ rescue NameError => e
21
+ raise e if exception
22
+ end
23
+ when Symbol
24
+ resolve_class(self.send(klass))
25
+ else
26
+ raise "Unknown class: #{klass}" if exception
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -10,6 +10,7 @@ end
10
10
  require_relative 'people/person_modifier'
11
11
  require_relative 'people/person_factory'
12
12
  require_relative 'people/base_parser'
13
+ require_relative 'people/person_attribute_parser'
13
14
  require_relative 'people/person_parser'
14
15
  require_relative 'people/default_parsers'
15
16
  require_relative 'people/person_entry_attribute_mapper'
@@ -0,0 +1,52 @@
1
+ module Eco
2
+ module API
3
+ module Common
4
+ module People
5
+
6
+ # Class to define a parser/serializer.
7
+ class PersonAttributeParser < Eco::Language::Models::ParserSerializer
8
+
9
+ # @see Eco::Language::Models::ParserSerializer#def_parser
10
+ # @note
11
+ # - additionally, you can declare a callback `active:` to determine if when the
12
+ # parser will be active/used.
13
+ # - this is important to help avoiding to set values that are not present in the input entry.
14
+ # - if you have doubts about using it or not, do not use it.
15
+ # @param active_when [Proc] that expects a list of internal attributes or the internal entry itself
16
+ # By default, an attribute paraser is active if in the entry to parse the internal attribute is present.
17
+ def def_parser(active_when: nil, &block)
18
+ @active_when = attribute_present(active_when)
19
+ super(&block)
20
+ end
21
+
22
+ # Determines if for a given source data to parse, this parser should be active or not
23
+ # @return [Boolean] `true` if there's no callback defined or there is and evaluates `true`
24
+ # when for the current data to parse. It returns `false` otherwise.
25
+ def parser_active?(source_data)
26
+ @active_when.call(source_data)
27
+ end
28
+
29
+ private
30
+
31
+ # by default, an attribute paraser is active if in the entry to parse
32
+ # the internal attribute is present
33
+ def attribute_present(active_when)
34
+ Proc.new do |source_data|
35
+ case source_data
36
+ when Array
37
+ keys = source_data
38
+ when Hash
39
+ keys = source_data.keys
40
+ else
41
+ keys = []
42
+ end
43
+
44
+ (source_data && keys.include?(self.attr)) ||
45
+ (active_when && active_when.call(source_data))
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -6,7 +6,7 @@ module Eco
6
6
  # @attr_reader core_attrs [Array<String>] core attributes that are present in the person entry.
7
7
  # @attr_reader details_attrs [Array<String>] schema details attributes that are present in the person entry.
8
8
  # @attr_reader account_attrs [Array<String>] account attributes that are present in the person entry.
9
- # @attr_reader all_attrs [Array<String>] all the attrs that are present in the person entry.
9
+ # @attr_reader all_attrs [Array<String>] all the attrs that are present in the person entry.
10
10
  # @attr_reader internal_attrs [Array<String>] all the internally named attributes that the person entry has.
11
11
  # @attr_reader aliased_attrs [Array<String>] only those internal attributes present in the person entry that have an internal/external name mapping.
12
12
  # @attr_reader direct_attrs [Array<String>] only those internal attributes present in the person entry that do **not** have an internal/external name mapping.
@@ -23,7 +23,7 @@ module Eco
23
23
  # - if `data` is a `Person` object, its behaviour is `serialise`.
24
24
  # - if `data` is **not** a `Person` object, it does a `parse`.
25
25
  # - currently **in rework**, so there may be subtle differences that make it temporarily unstable (yet it is reliable).
26
- # @param data [Hash, Person] `Person` object to be serialized or hashed entry (`CSV::Row` is accepted).
26
+ # @param data [Hash, Person] `Person` object to be serialized or hashed entry (note: `CSV::Row` is accepted).
27
27
  # @param person_parser [Common::People::PersonParser] parser/serializer of person attributes (it contains a set of attribute parsers).
28
28
  # @param attr_map [Eco::Data::Mapper] mapper to translate attribute names from _external_ to _internal_ names and _vice versa_.
29
29
  # @param logger [Common::Session::Logger, ::Logger] object to manage logs.
@@ -43,12 +43,6 @@ module Eco
43
43
  @all_attrs = CORE_ATTRS + ACCOUNT_ATTRS + @details_attrs
44
44
  end
45
45
 
46
- # Lists all defined attributes, types and formats.
47
- # @return [Array<String>] the list of defined parsers/serializers.
48
- def list_defined
49
- @parsers.keys
50
- end
51
-
52
46
  # Scopes `source_attrs` using the _**core** attributes_.
53
47
  # @note use this helper to know which among your attributes are **core** ones.
54
48
  # @param source_attrs [Array<String>]
@@ -76,14 +70,26 @@ module Eco
76
70
  scoped_attrs(source_attrs, ACCOUNT_ATTRS)
77
71
  end
78
72
 
73
+ # Lists all defined attributes, types and formats.
74
+ # @return [Array<String>] the list of defined parsers/serializers.
75
+ #def list_defined
76
+ # @parsers.keys
77
+ #end
78
+
79
79
  # Returns a list of all the internal attributes of the model that have a parser defined.
80
- # @note it excludes any parser that is not in the model, such as type parsers (i.e. ``:boolean`, ``:multiple`)
80
+ # @note it excludes any parser that is not in the model, such as type parsers (i.e. `:boolean`, `:multiple`)
81
81
  # @return [Array<String>] list of all attribute defined parsers.
82
82
  def defined_attrs
83
83
  defined = @parsers.keys
84
84
  defined - (defined - all_attrs)
85
85
  end
86
86
 
87
+ # Returns a list of all the internal attributes of the model that have a parser defined & that should be active.
88
+ # @return [Array<String>] list of all attribute defined parsers that should be active.
89
+ def active_attrs(source_data)
90
+ defined_attrs.select {|attr| @parsers[attr].parser_active?(source_data)}
91
+ end
92
+
87
93
  # Returns a list of all the internal attributes of the model that do **not** have a parser defined.
88
94
  # @note it excludes any parser that is **not** in the model, such as type parsers (i.e. :boolean, :multiple)
89
95
  # @return [Array<String>] list of all attributes without a defined parser.
@@ -123,8 +129,8 @@ module Eco
123
129
  msg = "The attribute '#{attr_to_str(attr)}' is not part of core, account or target schema, or does not match any type: #{@details_attrs}"
124
130
  raise msg
125
131
  end
126
-
127
- Eco::Language::Models::ParserSerializer.new(attr, dependencies: dependencies).tap do |parser|
132
+ # Eco::Language::Models::ParserSerializer
133
+ Eco::API::Common::People::PersonAttributeParser.new(attr, dependencies: dependencies).tap do |parser|
128
134
  @parsers[attr] = parser
129
135
  definition.call(parser)
130
136
  end
@@ -169,7 +175,7 @@ module Eco
169
175
 
170
176
  def scoped_attrs(source_attrs, section_attrs)
171
177
  direct_attrs = source_attrs & section_attrs
172
- parsed_attrs = @parsers.keys & section_attrs
178
+ parsed_attrs = active_attrs(source_attrs) & section_attrs
173
179
  (source_attrs + parsed_attrs) & (direct_attrs + parsed_attrs)
174
180
  end
175
181
 
@@ -7,6 +7,5 @@ module Eco
7
7
  end
8
8
  end
9
9
 
10
- require_relative 'version_patches/base_model.rb'
11
- require_relative 'version_patches/external_person.rb'
12
- require_relative 'version_patches/internal_person.rb'
10
+ require_relative 'version_patches/hash'
11
+ require_relative 'version_patches/ecoportal_api'
@@ -0,0 +1,4 @@
1
+ require 'ecoportal/api'
2
+ require_relative 'ecoportal_api/base_model'
3
+ require_relative 'ecoportal_api/external_person'
4
+ require_relative 'ecoportal_api/internal_person'
@@ -0,0 +1,2 @@
1
+
2
+ require_relative 'hash/deep_merge'
@@ -0,0 +1,34 @@
1
+ class Hash
2
+ # Source: `ActiveSupport`
3
+ # - https://github.com/rails/rails/blob/b2eb1d1c55a59fee1e6c4cba7030d8ceb524267c/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
4
+ # Returns a new hash with +self+ and +other_hash+ merged recursively.
5
+ #
6
+ # h1 = { a: true, b: { c: [1, 2, 3] } }
7
+ # h2 = { a: false, b: { x: [3, 4, 5] } }
8
+ #
9
+ # h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
10
+ #
11
+ # Like with Hash#merge in the standard library, a block can be provided
12
+ # to merge values:
13
+ #
14
+ # h1 = { a: 100, b: 200, c: { c1: 100 } }
15
+ # h2 = { b: 250, c: { c1: 200 } }
16
+ # h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
17
+ # # => { a: 100, b: 450, c: { c1: 300 } }
18
+ def deep_merge(other_hash, &block)
19
+ dup.deep_merge!(other_hash, &block)
20
+ end
21
+
22
+ # Same as +deep_merge+, but modifies +self+.
23
+ def deep_merge!(other_hash, &block)
24
+ merge!(other_hash) do |key, this_val, other_val|
25
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
26
+ this_val.deep_merge(other_val, &block)
27
+ elsif block_given?
28
+ block.call(key, this_val, other_val)
29
+ else
30
+ other_val
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,133 @@
1
+ module Eco
2
+ module API
3
+ class Error < Exception
4
+ class UnknownErrorClass < Exception
5
+ def initialize(msg = nil, klass:)
6
+ msg ||= "Unkown api error class #{klass}"
7
+ super(msg)
8
+ end
9
+ end
10
+
11
+ @str_err = "api error on the server reply"
12
+ @match = /.*/
13
+ #RxValidId = /[a-f0-9]{24}/
14
+
15
+ class Unclassified < Eco::API::Error
16
+ @str_error = "Unclassified error message"
17
+ @match = /.*/
18
+ end
19
+
20
+ class UnknownPersonId < Eco::API::Error
21
+ @str_err = "Unknown person id"
22
+ @match = /Cannot find person with id (.*)/
23
+ end
24
+ class EmailMissing < Eco::API::Error
25
+ @str_err = "missing email for account creation"
26
+ @match = /#{@str_err}/
27
+ end
28
+ class EmailInvalid < Eco::API::Error
29
+ @str_err = "Email is invalid"
30
+ @match = /#{@str_err}/
31
+ end
32
+ class EmailTaken < Eco::API::Error
33
+ @str_err = "user email already taken"
34
+ @match = /#{@str_err}/
35
+ end
36
+ class SupervisorNotFound < Eco::API::Error
37
+ @str_err = "Supervisor not found"
38
+ @match = /Supervisor (.*?) not found/
39
+ end
40
+ class CyclicSupervisor < Eco::API::Error
41
+ @str_err = "Supervisor is cyclic!"
42
+ @match = /#{@str_err}/
43
+ end
44
+ class SchemaNotFound < Eco::API::Error
45
+ @str_err = "Schema not found"
46
+ @match = /Schema (.*?) not found/
47
+ end
48
+ class InvalidObjectId < Eco::API::Error
49
+ @str_err = "Invalid ObjectId."
50
+ @match = /'(.*?)' is an invalid ObjectId./
51
+ end
52
+ class UnkownField < Eco::API::Error
53
+ @str_err = "Unknown field."
54
+ @match = /(.+?) is an unknown field/
55
+
56
+ class UnkownCoreField < UnkownField
57
+ @str_err = "Unknown core field."
58
+ @match = /(.+?) is an unknown field/
59
+ end
60
+ class UnkownAccountField < UnkownField
61
+ @str_err = "Unknown account field."
62
+ @match = /account \> (.+?) is an unknown field/
63
+ end
64
+ class UnkownDetailsField < UnkownField
65
+ @str_err = "Unknown details field."
66
+ @match = /details \> (.+?) is an unknown field/
67
+ end
68
+
69
+ end
70
+
71
+ class << self
72
+ def descendants(direct: false)
73
+ ObjectSpace.each_object(::Class).select do |klass|
74
+ klass < self
75
+ end.tap do |siblings|
76
+ if direct
77
+ siblings.reject! do |si|
78
+ siblings.any? {|s| si < s}
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ def descendants?(direct: false)
85
+ descendants(direct: direct).length > 0
86
+ end
87
+
88
+ def err_match?(err_msg)
89
+ err_msg =~ @match
90
+ end
91
+
92
+ def get_type(err_msg)
93
+ type = nil
94
+ descendants(direct: true).reverse.each do |klass|
95
+ if klass.err_match?(err_msg)
96
+ type = klass
97
+ if klass.descendants?(direct: true)
98
+ type = klass.get_type(err_msg) || type
99
+ end
100
+ end
101
+ end
102
+ type
103
+ end
104
+
105
+ def known_err_class?(klass)
106
+ descendants.push(self).include?(klass)
107
+ end
108
+
109
+ def validate_err_class(klass)
110
+ raise UnknownErrorClass.new(klass: klass) unless known_err_class?(klass)
111
+ end
112
+ end
113
+
114
+ attr_reader :msg, :err_msg, :session, :entry
115
+
116
+ def initialize(msg = nil, err_msg:, session: nil, entry: nil)
117
+ @msg = msg
118
+ @err_msg = err_msg
119
+ @session = session
120
+ @entry = entry
121
+
122
+ super(built_error)
123
+ end
124
+
125
+ def built_error
126
+ str ||= msg
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ require_relative 'error/handler'
133
+ require_relative 'error/handlers'
@@ -0,0 +1,19 @@
1
+ module Eco
2
+ module API
3
+ class Error
4
+ class Handler < Eco::API::UseCases::UseCase
5
+ @types = [:transform]
6
+
7
+ def initialize(name, type: :transform, root:, &block)
8
+ super(name, type: type, root: root, &block)
9
+ end
10
+
11
+ def root=(value)
12
+ raise "Root should be a Eco::API::Error::Handlers object. Given: #{value}" if !value.is_a?(Eco::API::Error::Handlers)
13
+ @root = value
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module Eco
2
+ module API
3
+ class Error
4
+ class Handlers < Eco::API::UseCases
5
+
6
+ def add(handler)
7
+ raise "Expected Eco::API::Error::Handler object. Given: #{policy}" unless handler.is_a?(Eco::API::Error::Handler)
8
+ super(handler)
9
+ end
10
+
11
+ def on(klass_err, type: :transform, retry: true, &block)
12
+ Eco::API::Error.validate_err_class(klass_err)
13
+ raise "Expected block but not given" unless block
14
+ Eco::API::Error::Handler.new(klass_err, type: type, root: self, &block).tap do |handler|
15
+ add(handler)
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end