servactory 1.6.3 → 1.6.4
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8baf1ff3aab8a43c92e83987cb5f4cfbc426be9aacabf5fe63dd01e133c891e
|
4
|
+
data.tar.gz: 0af5e8fe8bf02fe5f15c68655e298b2d097b402764d231045683907afa35ded3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa8ffc01e6bab482d397f07e18847ec5d0b70bbd1e94bf7ff1ab6f080efca2502547ee92db3b663ba2bac15c2c6add762094ab37d9c47b73eb7b66f8f3ed9b10
|
7
|
+
data.tar.gz: a15fc2c38e21b6637ff5b9f1273006c0aae2dfe5d8d084390a18e2ce262329510fe80ab2bc16d47f18f3da8a40c5f5daea0533ad4b611a0e9ce8868eacf87b8f
|
@@ -5,10 +5,14 @@ module Servactory
|
|
5
5
|
class Collection
|
6
6
|
# NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
|
7
7
|
extend Forwardable
|
8
|
-
def_delegators :@collection, :<<, :each, :merge, :empty?
|
8
|
+
def_delegators :@collection, :<<, :each, :merge, :sort_by, :size, :empty?
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@collection =
|
10
|
+
def initialize(collection = Set.new)
|
11
|
+
@collection = collection
|
12
|
+
end
|
13
|
+
|
14
|
+
def sorted_by_position
|
15
|
+
Collection.new(sort_by(&:position))
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
@@ -16,8 +16,12 @@ module Servactory
|
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def make(name, **options)
|
20
|
-
collection_of_methods << Method.new(
|
19
|
+
def make(name, position: nil, **options)
|
20
|
+
collection_of_methods << Method.new(
|
21
|
+
name,
|
22
|
+
position: position.presence || next_position,
|
23
|
+
**options
|
24
|
+
)
|
21
25
|
end
|
22
26
|
|
23
27
|
def method_missing(shortcut_name, *args, &block)
|
@@ -34,6 +38,10 @@ module Servactory
|
|
34
38
|
Servactory.configuration.method_shortcuts.include?(shortcut_name) || super
|
35
39
|
end
|
36
40
|
|
41
|
+
def next_position
|
42
|
+
collection_of_methods.size + 1
|
43
|
+
end
|
44
|
+
|
37
45
|
def collection_of_methods
|
38
46
|
@collection_of_methods ||= Collection.new
|
39
47
|
end
|
@@ -4,11 +4,13 @@ module Servactory
|
|
4
4
|
module Methods
|
5
5
|
class Method
|
6
6
|
attr_reader :name,
|
7
|
+
:position,
|
7
8
|
:condition,
|
8
9
|
:is_condition_opposite
|
9
10
|
|
10
|
-
def initialize(name, **options)
|
11
|
+
def initialize(name, position:, **options)
|
11
12
|
@name = name
|
13
|
+
@position = position
|
12
14
|
|
13
15
|
@is_condition_opposite = false
|
14
16
|
@condition = options.fetch(:if, nil)
|
@@ -18,7 +18,7 @@ module Servactory
|
|
18
18
|
def run!
|
19
19
|
return try_to_use_call if collection_of_methods.empty?
|
20
20
|
|
21
|
-
collection_of_methods.each do |make_method|
|
21
|
+
collection_of_methods.sorted_by_position.each do |make_method|
|
22
22
|
next if unnecessary_for?(make_method)
|
23
23
|
|
24
24
|
context.send(make_method.name)
|
data/lib/servactory/version.rb
CHANGED
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.6.
|
4
|
+
version: 1.6.4
|
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-
|
11
|
+
date: 2023-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|