foobara 0.0.32 → 0.0.34

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: c792e842511e06c18b7104b2d417b4ba93275266f94257207176f9c6eed4265f
4
- data.tar.gz: 4ce865c5dd74d839710bdb4a766e47e645ab07e4a484cf32ede9ed839e3d75a9
3
+ metadata.gz: bc9733f9966487e9f526b01792182ff02718e7f3ac445256d24397942eddf4ec
4
+ data.tar.gz: 4e611e1bfae4bc3418108ad93680555e6497d1426a465697827064523ed940d5
5
5
  SHA512:
6
- metadata.gz: 5d0d59e0a8bd59703873c845a06a9afb756c8326700f8858eeeff476cde1ad3b20386037008211db6878727eb6585d9d7cd4b8e4892e784d65028c9d19060db1
7
- data.tar.gz: a45f976f9a90d78a1f6e4ae2077da4846565a89c2092a0cf7da92ab068dda6ef25b2ec1f8700824ff29c3dc58b53f4ebc0bdf35984b865c6cb91c63136327204
6
+ metadata.gz: a57062ce5885cc626ac32c66dcf9902c1ace2d50d2182c0ec188ba01e3bc662f9e0d6e2fe4d8b6626a23b25f1046e71da813d0b35e8b3d37c895f074d901feb7
7
+ data.tar.gz: 7d6724fff8dc1ee6961f6585ab9c5b78560962725511cd3d316451dda387d8455ddc0a9808c8617aabed61d4aeb656698a1b7a92ef2b760a7248c96bc6b84f81
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
- ## [0.0.32] - 2024-12-09
1
+ ## [0.0.34] - 2024-12-10
2
+
3
+ - Fix bug with command-named convenience functions
4
+
5
+ ## [0.0.33] - 2024-12-09
2
6
 
3
7
  - Introduce a DetachedEntity concept that sits between Model and Entity
4
8
  - Add a detached_to_primary_key flag to EntitiesToPrimaryKeysSerializer
9
+ - Create command-named convenience functions for .run! calls
5
10
 
6
11
  ## [0.0.30] - 2024-12-07
7
12
 
@@ -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
@@ -22,6 +22,9 @@ module Foobara
22
22
  include Concerns::DomainMappers
23
23
  include Concerns::Reflection
24
24
 
25
+ # TODO: this feels like a hack and shouldn't be necessary. Let's try to fix Concern class inheritance, instead.
26
+ self.subclass_defined_callbacks ||= Foobara::Callback::Registry::SingleAction.new
27
+
25
28
  attr_reader :raw_inputs
26
29
 
27
30
  def initialize(inputs = {})
@@ -32,5 +35,6 @@ module Foobara
32
35
 
33
36
  Command.after_subclass_defined do |subclass|
34
37
  Command.all << subclass
38
+ subclass.define_command_named_function
35
39
  end
36
40
  end
@@ -4,11 +4,9 @@ module Foobara
4
4
  module Callbacks
5
5
  include Concern
6
6
 
7
- module ClassMethods
8
- def subclass_defined_callbacks
9
- @subclass_defined_callbacks ||= Foobara::Callback::Registry::SingleAction.new
10
- end
7
+ inherited_overridable_class_attr_accessor :subclass_defined_callbacks
11
8
 
9
+ module ClassMethods
12
10
  def inherited(subclass)
13
11
  super
14
12
 
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -24,8 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: Implements command pattern for encapsulating and managing domain complexity
28
- as well as many supporting libraries including entities.
27
+ description: A command-centric and discoverable software framework with a focus on
28
+ domain concepts and abstracting away integration code
29
29
  email:
30
30
  - azimux@gmail.com
31
31
  executables: []
@@ -423,6 +423,6 @@ requirements: []
423
423
  rubygems_version: 3.5.23
424
424
  signing_key:
425
425
  specification_version: 4
426
- summary: Implements command pattern for encapsulating and managing domain complexity
427
- as well as many supporting libraries including entities.
426
+ summary: A command-centric and discoverable software framework with a focus on domain
427
+ concepts and abstracting away integration code
428
428
  test_files: []