servactory 1.9.3 → 1.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 026f0a67d02ac1eb1053768585e80684a7bbaa4acbf3b381213d145cfbefe4ae
4
- data.tar.gz: 362040a5cfe9b33d28b1a83bedb21efa7d2fa701272c7b30f739c6a8f025af42
3
+ metadata.gz: 160e4621b678dca239c604c460984aa15cbc79ffceac023357097560a06b51bd
4
+ data.tar.gz: 3dcb288a82252259d88ec0ce2f54f6c35ad9c74237acc0f6f61fa6c10794df39
5
5
  SHA512:
6
- metadata.gz: 449c7dd9083b99629621e0cd04bcbd07e3b01b3081fc64cc36042922d3c8fa603a8f2efb6d14fe53b8b233ec9437bf82d994831e5cbc002b4ccad5829775ea1d
7
- data.tar.gz: 932159f75fb820fd9adad6f0f2bb6bae88e2ac74d87d9e2293caab4c5a5cb691a6d161bfe4ac4e3f89527b2f106ff52d36119cbb765ccbed2767cb70ab1b8b2d
6
+ metadata.gz: 20ced1c8f1d44e0e95ed8860f2e02e55c36a7c52148929ba6d726de4f7667503cb55b57e9e13e110247a8ae7a19673d01526196e2e21891a6bbff6fb4e7807c3
7
+ data.tar.gz: 1852aa185591e50ccff9c46be4384b4e91fc7ace9c2ecb7e526bfaa4025aec8a9030484d6a5297a3957333b20a8e484e5b23e86b7a3c9c148d1c4f9952656f5e
@@ -10,10 +10,22 @@ module Servactory
10
10
  @collection_of_inputs = collection_of_inputs
11
11
  end
12
12
 
13
- def method_missing(name, *args, &block)
14
- prepared_name = name.to_s.delete("=").to_sym
13
+ def only(*names)
14
+ @collection_of_inputs
15
+ .only(*names)
16
+ .to_h { |input| [input.internal_name, send(input.internal_name)] }
17
+ end
18
+
19
+ def except(*names)
20
+ @collection_of_inputs
21
+ .except(*names)
22
+ .to_h { |input| [input.internal_name, send(input.internal_name)] }
23
+ end
15
24
 
25
+ def method_missing(name, *_args)
16
26
  if name.to_s.end_with?("=")
27
+ prepared_name = name.to_s.delete("=").to_sym
28
+
17
29
  raise_error_for(:setter, prepared_name)
18
30
  else
19
31
  getter_with(name: name) { raise_error_for(:getter, name) }
@@ -9,13 +9,25 @@ module Servactory
9
9
  @collection_of_internals = collection_of_internals
10
10
  end
11
11
 
12
- def method_missing(name, *args, &block)
13
- prepared_name = name.to_s.delete("=").to_sym
12
+ def only(*names)
13
+ @collection_of_internals
14
+ .only(*names)
15
+ .to_h { |internal| [internal.name, send(internal.name)] }
16
+ end
17
+
18
+ def except(*names)
19
+ @collection_of_internals
20
+ .except(*names)
21
+ .to_h { |internal| [internal.name, send(internal.name)] }
22
+ end
14
23
 
24
+ def method_missing(name, *args)
15
25
  if name.to_s.end_with?("=")
26
+ prepared_name = name.to_s.delete("=").to_sym
27
+
16
28
  setter_with(prepared_name: prepared_name, value: args.pop) { raise_error_for(:setter, prepared_name) }
17
29
  else
18
- getter_with(name: name) { raise_error_for(:getter, prepared_name) }
30
+ getter_with(name: name) { raise_error_for(:getter, name) }
19
31
  end
20
32
  end
21
33
 
@@ -38,7 +50,7 @@ module Servactory
38
50
  value: value
39
51
  )
40
52
 
41
- @context.send(:assign_internal, internal.name, value)
53
+ @context.send(:assign_servactory_service_storage_internal, internal.name, value)
42
54
  end
43
55
 
44
56
  def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
@@ -47,7 +59,7 @@ module Servactory
47
59
 
48
60
  return yield if internal.nil?
49
61
 
50
- internal_value = @context.send(:fetch_internal, internal.name)
62
+ internal_value = @context.send(:fetch_servactory_service_storage_internal, internal.name)
51
63
 
52
64
  if name.to_s.end_with?("?")
53
65
  Servactory::Utils.query_attribute(internal_value)
@@ -9,13 +9,25 @@ module Servactory
9
9
  @collection_of_outputs = collection_of_outputs
10
10
  end
11
11
 
12
- def method_missing(name, *args, &block)
13
- prepared_name = name.to_s.delete("=").to_sym
12
+ def only(*names)
13
+ @collection_of_outputs
14
+ .only(*names)
15
+ .to_h { |output| [output.name, send(output.name)] }
16
+ end
17
+
18
+ def except(*names)
19
+ @collection_of_outputs
20
+ .except(*names)
21
+ .to_h { |output| [output.name, send(output.name)] }
22
+ end
14
23
 
24
+ def method_missing(name, *args)
15
25
  if name.to_s.end_with?("=")
26
+ prepared_name = name.to_s.delete("=").to_sym
27
+
16
28
  setter_with(prepared_name: prepared_name, value: args.pop) { raise_error_for(:setter, prepared_name) }
17
29
  else
18
- getter_with(name: name) { raise_error_for(:getter, prepared_name) }
30
+ getter_with(name: name) { raise_error_for(:getter, name) }
19
31
  end
20
32
  end
21
33
 
@@ -38,7 +50,7 @@ module Servactory
38
50
  value: value
39
51
  )
40
52
 
41
- @context.send(:assign_output, output.name, value)
53
+ @context.send(:assign_servactory_service_storage_output, output.name, value)
42
54
  end
43
55
 
44
56
  def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
@@ -47,7 +59,7 @@ module Servactory
47
59
 
48
60
  return yield if output.nil?
49
61
 
50
- output_value = @context.send(:fetch_output, output.name)
62
+ output_value = @context.send(:fetch_servactory_service_storage_output, output.name)
51
63
 
52
64
  if name.to_s.end_with?("?")
53
65
  Servactory::Utils.query_attribute(output_value)
@@ -84,24 +84,24 @@ module Servactory
84
84
  )
85
85
  end
86
86
 
87
- def service_storage
88
- @service_storage ||= { internals: {}, outputs: {} }
87
+ def servactory_service_storage
88
+ @servactory_service_storage ||= { internals: {}, outputs: {} }
89
89
  end
90
90
 
91
- def assign_internal(key, value)
92
- service_storage[:internals].merge!({ key => value })
91
+ def assign_servactory_service_storage_internal(key, value)
92
+ servactory_service_storage[:internals].merge!({ key => value })
93
93
  end
94
94
 
95
- def fetch_internal(key)
96
- service_storage.fetch(:internals).fetch(key, nil)
95
+ def fetch_servactory_service_storage_internal(key)
96
+ servactory_service_storage.fetch(:internals).fetch(key, nil)
97
97
  end
98
98
 
99
- def assign_output(key, value)
100
- service_storage[:outputs].merge!({ key => value })
99
+ def assign_servactory_service_storage_output(key, value)
100
+ servactory_service_storage[:outputs].merge!({ key => value })
101
101
  end
102
102
 
103
- def fetch_output(key)
104
- service_storage.fetch(:outputs).fetch(key, nil)
103
+ def fetch_servactory_service_storage_output(key)
104
+ servactory_service_storage.fetch(:outputs).fetch(key, nil)
105
105
  end
106
106
  end
107
107
  end
@@ -3,12 +3,19 @@
3
3
  module Servactory
4
4
  module Inputs
5
5
  class Collection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
- def_delegators :@collection, :<<, :each, :map, :merge, :find
7
+ def_delegators :@collection, :<<, :filter, :each, :map, :to_h, :merge, :find
9
8
 
10
- def initialize(*)
11
- @collection = Set.new
9
+ def initialize(collection = Set.new)
10
+ @collection = collection
11
+ end
12
+
13
+ def only(*names)
14
+ Collection.new(filter { |input| names.include?(input.internal_name) })
15
+ end
16
+
17
+ def except(*names)
18
+ Collection.new(filter { |input| !names.include?(input.internal_name) })
12
19
  end
13
20
 
14
21
  def names
@@ -21,7 +21,7 @@ module Servactory
21
21
  collection_of_inputs << Input.new(
22
22
  name,
23
23
  *helpers,
24
- config: config,
24
+ option_helpers: config.input_option_helpers,
25
25
  **options
26
26
  )
27
27
  end
@@ -9,7 +9,7 @@ module Servactory
9
9
 
10
10
  attr_reader :name,
11
11
  :internal_name,
12
- :config
12
+ :option_helpers
13
13
 
14
14
  # rubocop:disable Style/KeywordParametersOrder
15
15
  def initialize(
@@ -17,12 +17,12 @@ module Servactory
17
17
  *helpers,
18
18
  as: nil,
19
19
  type:,
20
- config:,
20
+ option_helpers:,
21
21
  **options
22
22
  )
23
23
  @name = name
24
24
  @internal_name = as.present? ? as : name
25
- @config = config
25
+ @option_helpers = option_helpers
26
26
 
27
27
  options = apply_helpers_for_options(helpers: helpers, options: options) if helpers.present?
28
28
 
@@ -46,7 +46,7 @@ module Servactory
46
46
  prepared_options = {}
47
47
 
48
48
  helpers.each do |helper|
49
- found_helper = config.input_option_helpers.find_by(name: helper)
49
+ found_helper = option_helpers.find_by(name: helper)
50
50
 
51
51
  next if found_helper.blank?
52
52
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Inputs
5
5
  class OptionHelpersCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :find, :merge
9
8
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Inputs
5
5
  class OptionsCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :filter, :each, :map, :flat_map, :find
9
8
 
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Inputs
5
5
  module Tools
6
6
  class CheckErrors
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :merge, :reject, :first, :empty?
10
9
 
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Inputs
5
5
  module Validations
6
6
  class Errors
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :<<, :to_a
10
9
 
@@ -3,12 +3,19 @@
3
3
  module Servactory
4
4
  module Internals
5
5
  class Collection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
- def_delegators :@collection, :<<, :each, :map, :merge, :find
7
+ def_delegators :@collection, :<<, :filter, :each, :map, :to_h, :merge, :find
9
8
 
10
- def initialize(*)
11
- @collection = Set.new
9
+ def initialize(collection = Set.new)
10
+ @collection = collection
11
+ end
12
+
13
+ def only(*names)
14
+ Collection.new(filter { |internal| names.include?(internal.name) })
15
+ end
16
+
17
+ def except(*names)
18
+ Collection.new(filter { |internal| !names.include?(internal.name) })
12
19
  end
13
20
 
14
21
  def names
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Methods
5
5
  module AliasesForMake
6
6
  class Collection
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :<<, :merge, :include?
10
9
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Methods
5
5
  class MethodCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :each, :sort_by
9
8
 
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Methods
5
5
  module ShortcutsForMake
6
6
  class Collection
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :<<, :each, :merge, :include?
10
9
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Methods
5
5
  class StageCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :each, :merge, :sort_by, :size, :empty?
9
8
 
@@ -42,7 +42,7 @@ module Servactory
42
42
  end
43
43
 
44
44
  def call_wrapper_with_methods(wrapper, rollback, methods)
45
- wrapper.call(methods: -> { call_methods(methods) })
45
+ wrapper.call(methods: -> { call_methods(methods) }, context: @context)
46
46
  rescue StandardError => e
47
47
  @context.send(rollback, e) if rollback.present?
48
48
  end
@@ -3,12 +3,19 @@
3
3
  module Servactory
4
4
  module Outputs
5
5
  class Collection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
- def_delegators :@collection, :<<, :each, :map, :merge, :find
7
+ def_delegators :@collection, :<<, :filter, :each, :map, :to_h, :merge, :find
9
8
 
10
- def initialize(*)
11
- @collection = Set.new
9
+ def initialize(collection = Set.new)
10
+ @collection = collection
11
+ end
12
+
13
+ def only(*names)
14
+ Collection.new(filter { |internal| names.include?(internal.name) })
15
+ end
16
+
17
+ def except(*names)
18
+ Collection.new(filter { |internal| !names.include?(internal.name) })
12
19
  end
13
20
 
14
21
  def names
@@ -25,7 +25,7 @@ module Servactory
25
25
  define_singleton_method(:success?) { true }
26
26
  define_singleton_method(:failure?) { false }
27
27
 
28
- @context.send(:service_storage).fetch(:outputs).each_pair do |key, value|
28
+ @context.send(:servactory_service_storage).fetch(:outputs).each_pair do |key, value|
29
29
  define_singleton_method(:"#{key}?") { Servactory::Utils.query_attribute(value) }
30
30
  define_singleton_method(key) { value }
31
31
  end
@@ -13,7 +13,7 @@ module Servactory
13
13
 
14
14
  def initialize(attributes = {})
15
15
  attributes.each_pair do |name, value|
16
- service_storage[:outputs].merge!({ name => value })
16
+ servactory_service_storage[:outputs].merge!({ name => value })
17
17
  end
18
18
  end
19
19
 
@@ -21,8 +21,8 @@ module Servactory
21
21
 
22
22
  private
23
23
 
24
- def service_storage
25
- @service_storage ||= { outputs: {} }
24
+ def servactory_service_storage
25
+ @servactory_service_storage ||= { outputs: {} }
26
26
  end
27
27
  end
28
28
  end
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 9
7
- PATCH = 3
7
+ PATCH = 5
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.3
4
+ version: 1.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-27 00:00:00.000000000 Z
11
+ date: 2023-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport