foobara 0.0.128 → 0.0.130

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: cb5fc138339eebd7dc6aafbe379a85ee8ea0a5f2d6dbd89b2e2fa590de679d26
4
- data.tar.gz: 1b706dfa3167fa9c67560b5f832da6dfa7b1608abb7f4f511ca5ffa82821b8d5
3
+ metadata.gz: 5dd322e7389be1e600f98133b9e92a177f1d14a1b2c0d4200e7b9630fd023983
4
+ data.tar.gz: 6518a4d6ac731b1973809640058b8e793ebcd9dc0d014827713fc2466fe209d9
5
5
  SHA512:
6
- metadata.gz: c71ac160e871eec0503faa700ebc08b38af97bdb9b55ed285802db7914e4c48289cd2130543963087e3c1d51e29515ab73f1d4295b02f1738ce84dd786fb3b75
7
- data.tar.gz: 55b37e7df5376fd8f840f74c7c2c7077bac73da827ff4b4426db4be8fb6fa4376095b1bb657be0e4ba85d9671b3a6b371be30a95afb9086f35db554d87f00717
6
+ metadata.gz: 96d8ca1ee65877ae7315052668cdff9c247ee778f5d285d4828145b3c69f06402fc97b4085744315f76b30dad36d5a9bd7f4a753108a1195950c4676c9cf16e1
7
+ data.tar.gz: a3ee1b0364e55f320ea2272b17f6a49d0a5e5a4d7406c3f9aa65fb8b04cdbf7b5c1169db6ae06adb3851edc62ae595614011a95b6b0ffa4767e672466f2c855c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [0.0.130] - 2025-06-06
2
+
3
+ - Support using a proc as an attributes default for lazy evaluation of default values
4
+
5
+ # [0.0.129] - 2025-05-30
6
+
7
+ - Store the raw, unprocessed, command result for debugging/introspection
8
+
1
9
  # [0.0.128] - 2025-05-29
2
10
 
3
11
  - Add StateMachine.for convenience method
data/README.md CHANGED
@@ -3,7 +3,7 @@ domain operations in commands, and automatically expose machine-readable formal
3
3
  commands so that integration code can be decoupled and abstracted away.
4
4
 
5
5
  This, as well as some other features of foobara, help manage domain complexity and produce
6
- more flexible systems with better management of domain complexity.
6
+ more flexible systems.
7
7
 
8
8
  You can watch a video that gives a good overview of what Foobara is and its goals here:
9
9
  [Introduction to the Foobara software framework](https://youtu.be/SSOmQqjNSVY)
@@ -27,7 +27,7 @@ You can watch a video that gives a good overview of what Foobara is and its goal
27
27
  * [HTTP Command Connectors](#http-command-connectors)
28
28
  * [Rack Connector](#rack-connector)
29
29
  * [Rails Connector](#rails-connector)
30
- * [MCP Command Connector](#mcp-command-connector)
30
+ * [MCP Command Connector](#mcp-command-connector)
31
31
  * [Async Command Connectors](#async-command-connectors)
32
32
  * [Scheduler Command Connectors](#scheduler-command-connectors)
33
33
  * [Intermediate Foobara](#intermediate-foobara)
@@ -834,7 +834,7 @@ end
834
834
 
835
835
  This has the same effect as the previous code and is just a stylistic alternative.
836
836
 
837
- ### MCP Command Connector
837
+ #### MCP Command Connector
838
838
 
839
839
  We can have an MCP server for free for our commands. Let's try it!
840
840
 
@@ -20,11 +20,11 @@ module Foobara
20
20
  allow_nil = parent_declaration_data[:element_type_declarations][attribute_name][:allow_nil]
21
21
 
22
22
  unless allow_nil
23
- to_apply[attribute_name] = default
23
+ to_apply[attribute_name] = default.is_a?(Proc) ? default.call : default
24
24
  end
25
25
  end
26
26
  else
27
- to_apply[attribute_name] = default
27
+ to_apply[attribute_name] = default.is_a?(Proc) ? default.call : default
28
28
  end
29
29
  end
30
30
 
@@ -18,6 +18,7 @@ module Foobara
18
18
  end
19
19
 
20
20
  attr_reader :outcome, :exception
21
+ attr_accessor :raw_result
21
22
 
22
23
  def run!
23
24
  run.result!
@@ -67,7 +68,7 @@ module Foobara
67
68
  end
68
69
 
69
70
  def run_execute
70
- raw_result = execute
71
+ self.raw_result = execute
71
72
  result = process_result_using_result_type(raw_result)
72
73
  @outcome = Outcome.success(result)
73
74
  end
@@ -1,3 +1,5 @@
1
+ require "yaml"
2
+
1
3
  module Foobara
2
4
  module CommandConnectors
3
5
  module Serializers
@@ -86,7 +86,10 @@ module Foobara
86
86
 
87
87
  defaults = attributes_type.declaration_data[:defaults]
88
88
  if defaults && !defaults.empty?
89
- record.write_attributes_without_callbacks(defaults)
89
+ resolved_defaults = defaults.transform_values do |value|
90
+ value.is_a?(Proc) ? value.call : value
91
+ end
92
+ record.write_attributes_without_callbacks(resolved_defaults)
90
93
  end
91
94
 
92
95
  record.write_attributes_without_callbacks(attributes)
@@ -32,16 +32,6 @@ module Foobara
32
32
  Util.deep_dup(records[record_id])
33
33
  end
34
34
 
35
- def find!(record_id)
36
- attributes = find(record_id)
37
-
38
- unless attributes
39
- raise CannotFindError.new(record_id, "does not exist")
40
- end
41
-
42
- attributes
43
- end
44
-
45
35
  def insert(attributes)
46
36
  attributes = Util.deep_dup(attributes)
47
37
 
@@ -273,7 +273,7 @@ module Foobara
273
273
  filter, method, bang = _filter_from_method_name(method_name)
274
274
 
275
275
  if filter
276
- method = "foobara_#{method}#{bang ? "!" : ""}"
276
+ method = "foobara_#{method}#{"!" if bang}"
277
277
  send(method, *, **, filter:, &)
278
278
  else
279
279
  # :nocov:
@@ -107,10 +107,14 @@ module Foobara
107
107
  # :nocov:
108
108
  end
109
109
 
110
- def find!(_record_id)
111
- # :nocov:
112
- raise "subclass responsibility"
113
- # :nocov:
110
+ def find!(record_id)
111
+ attributes = find(record_id)
112
+
113
+ unless attributes
114
+ raise CannotFindError.new(record_id, "does not exist")
115
+ end
116
+
117
+ attributes
114
118
  end
115
119
 
116
120
  def find_many!(record_ids)
@@ -86,6 +86,7 @@ module Foobara
86
86
  # :nocov:
87
87
  end
88
88
 
89
+ # rubocop:disable Lint/IdentityComparison
89
90
  if entity &&
90
91
  (!entity.equal?(entity_or_record_id) || entity.object_id != entity_or_record_id.object_id)
91
92
  # :nocov:
@@ -93,6 +94,7 @@ module Foobara
93
94
  "Try passing in the primary key instead of constructing an unloaded entity to pass in."
94
95
  # :nocov:
95
96
  end
97
+ # rubocop:enable Lint/IdentityComparison
96
98
 
97
99
  record_id = entity.primary_key
98
100
  else
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.128
4
+ version: 0.0.130
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -41,16 +41,16 @@ dependencies:
41
41
  name: foobara-util
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.0.11
46
+ version: 1.0.0
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.0.11
53
+ version: 1.0.0
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: inheritable-thread-vars
56
56
  requirement: !ruby/object:Gem::Requirement