silas 0.6.2 → 0.6.3

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.
data/lib/silas/tool.rb CHANGED
@@ -23,16 +23,16 @@ module Silas
23
23
  class << self
24
24
  def description(text = nil)
25
25
  @description = text if text
26
- @description || ""
26
+ inherited_setting(:@description) || ""
27
27
  end
28
28
 
29
29
  def param(name, type = :string, desc: nil)
30
- param_refinements[name.to_sym] = { type: type.to_s, desc: desc }
30
+ own_param_refinements[name.to_sym] = { type: type.to_s, desc: desc }
31
31
  end
32
32
 
33
33
  def approval(policy = nil, &block)
34
34
  @approval_policy = block || policy unless policy.nil? && block.nil?
35
- @approval_policy || :never
35
+ inherited_setting(:@approval_policy) || :never
36
36
  end
37
37
  alias approval_policy approval
38
38
 
@@ -40,7 +40,7 @@ module Silas
40
40
  def idempotent! = @effect_mode = :idempotent
41
41
  def at_most_once! = @effect_mode = :at_most_once
42
42
 
43
- def effect_mode = @effect_mode || :at_most_once
43
+ def effect_mode = inherited_setting(:@effect_mode) || :at_most_once
44
44
 
45
45
  def tool_name
46
46
  name.demodulize.underscore
@@ -79,9 +79,42 @@ module Silas
79
79
 
80
80
  private
81
81
 
82
- def param_refinements
82
+ # Ruby does NOT inherit class-level instance variables. Without this walk,
83
+ # factoring shared declarations into a base class —
84
+ #
85
+ # class MoneyTool < Silas::Tool
86
+ # transactional!
87
+ # approval :always
88
+ # end
89
+ # class IssueRefund < MoneyTool; end
90
+ #
91
+ # — silently drops both in the subclass, and drops them into the LEAST
92
+ # safe defaults: no database transaction (:at_most_once) and no human
93
+ # gate (:never). Silently disarming the two declarations the ledger acts
94
+ # on is the worst failure this DSL could have, so settings resolve up the
95
+ # ancestry: nearest explicit declaration wins.
96
+ def inherited_setting(ivar)
97
+ klass = self
98
+ while klass.respond_to?(:inherited_setting, true)
99
+ value = klass.instance_variable_get(ivar)
100
+ return value unless value.nil?
101
+
102
+ klass = klass.superclass
103
+ end
104
+ nil
105
+ end
106
+
107
+ def own_param_refinements
83
108
  @param_refinements ||= {}
84
109
  end
110
+
111
+ # Merged down the ancestry so a base class's `param` refinements survive;
112
+ # a subclass redeclaring the same param wins.
113
+ def param_refinements
114
+ return own_param_refinements unless superclass.respond_to?(:param_refinements, true)
115
+
116
+ superclass.send(:param_refinements).merge(own_param_refinements)
117
+ end
85
118
  end
86
119
 
87
120
  # Instance-side delegation so a resolved instance answers the Ledger.
data/lib/silas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Silas
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: silas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel St Paul
@@ -146,7 +146,9 @@ files:
146
146
  - app/views/silas/channels/approvals/error.html.erb
147
147
  - app/views/silas/channels/approvals/show.html.erb
148
148
  - app/views/silas/inbox/invocations/_approval_card.html.erb
149
+ - app/views/silas/inbox/invocations/_detail.html.erb
149
150
  - app/views/silas/inbox/invocations/_invocation.html.erb
151
+ - app/views/silas/inbox/sessions/_child.html.erb
150
152
  - app/views/silas/inbox/sessions/_cost.html.erb
151
153
  - app/views/silas/inbox/sessions/_row.html.erb
152
154
  - app/views/silas/inbox/sessions/index.html.erb
@@ -175,11 +177,13 @@ files:
175
177
  - docs/conventions.md
176
178
  - docs/evals.md
177
179
  - docs/guarantees.md
180
+ - docs/headless.md
178
181
  - docs/inbox-and-api.md
179
182
  - docs/memory.md
180
183
  - docs/providers.md
181
184
  - docs/sandbox.md
182
185
  - docs/tools.md
186
+ - docs/traces.md
183
187
  - docs/tutorial.md
184
188
  - docs/vs-eve.md
185
189
  - docs/why-silas.md