foobara 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/projects/command/lib/foobara/command.rb +24 -0
- data/projects/command/src/command.rb +1 -0
- data/projects/command/src/concerns/runtime.rb +38 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0fa3ca995bce92b12bb618474cd34f96c6620c110cc73e02cd4b66f2a572fab
|
4
|
+
data.tar.gz: e1155dc5793d694c039fc0e7ab5f4d4112c60b8bc3be6eb24d68cb4d277fb2ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 102f6110c8cbef54564e34309da3c61a7d4f97fe67dd8def94b15523b466979c12f8bffe1e7343b08fde95269645d40a6f140cf117514bab92da406fd2a8edff
|
7
|
+
data.tar.gz: 99dc5ad01438bb404ea4da952423d3e414d2526647aa682c10bb3333c0833904de27b29eed1b15c22741d72317103875eed001a56eb2aa8ffd72c7230f30c459
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
## [0.0.
|
1
|
+
## [0.0.33] - 2024-12-09
|
2
2
|
|
3
3
|
- Introduce a DetachedEntity concept that sits between Model and Entity
|
4
4
|
- Add a detached_to_primary_key flag to EntitiesToPrimaryKeysSerializer
|
5
|
+
- Create command-named convenience functions for .run! calls
|
5
6
|
|
6
7
|
## [0.0.30] - 2024-12-07
|
7
8
|
|
@@ -4,6 +4,30 @@ module Foobara
|
|
4
4
|
def install!
|
5
5
|
Namespace.global.foobara_add_category_for_subclass_of(:command, self)
|
6
6
|
end
|
7
|
+
|
8
|
+
def reset_all
|
9
|
+
to_delete = []
|
10
|
+
|
11
|
+
all.each do |command_class|
|
12
|
+
if command_class.name.include?("::")
|
13
|
+
parent_name = Util.parent_module_name_for(command_class.name)
|
14
|
+
|
15
|
+
if Object.const_defined?(parent_name)
|
16
|
+
command_class.undefine_command_named_function
|
17
|
+
else
|
18
|
+
to_delete << command_class
|
19
|
+
end
|
20
|
+
else
|
21
|
+
command_class.undefine_command_named_function
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
to_delete.each do |command_class|
|
26
|
+
all.delete(command_class)
|
27
|
+
end
|
28
|
+
|
29
|
+
super
|
30
|
+
end
|
7
31
|
end
|
8
32
|
end
|
9
33
|
end
|
@@ -15,6 +15,44 @@ module Foobara
|
|
15
15
|
def run!(...)
|
16
16
|
new(...).run!
|
17
17
|
end
|
18
|
+
|
19
|
+
def define_command_named_function
|
20
|
+
command_class = self
|
21
|
+
convenience_method_name = Foobara::Util.non_full_name(command_class)
|
22
|
+
containing_module = Foobara::Util.module_for(command_class) || Object
|
23
|
+
|
24
|
+
if containing_module.is_a?(::Class)
|
25
|
+
containing_module.singleton_class.define_method convenience_method_name do |*args, **opts, &block|
|
26
|
+
command_class.run!(*args, **opts, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
containing_module.define_method convenience_method_name do |*args, **opts, &block|
|
30
|
+
command_class.run!(*args, **opts, &block)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
containing_module.module_eval do
|
34
|
+
module_function
|
35
|
+
|
36
|
+
define_method convenience_method_name do |*args, **opts, &block|
|
37
|
+
command_class.run!(*args, **opts, &block)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def undefine_command_named_function
|
44
|
+
command_class = self
|
45
|
+
convenience_method_name = Foobara::Util.non_full_name(command_class)
|
46
|
+
containing_module = Foobara::Util.module_for(command_class) || Object
|
47
|
+
|
48
|
+
return unless containing_module.respond_to?(convenience_method_name)
|
49
|
+
|
50
|
+
containing_module.singleton_class.undef_method convenience_method_name
|
51
|
+
|
52
|
+
if containing_module.is_a?(::Class)
|
53
|
+
containing_module.undef_method convenience_method_name
|
54
|
+
end
|
55
|
+
end
|
18
56
|
end
|
19
57
|
|
20
58
|
attr_reader :outcome, :exception
|