servactory 3.0.0.rc1 → 3.0.0.rc3
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 +4 -4
- data/lib/servactory/dsl.rb +9 -9
- data/lib/servactory/maintenance/attributes/option.rb +1 -5
- data/lib/servactory/maintenance/attributes/options_collection.rb +75 -3
- data/lib/servactory/tool_kit/dynamic_options/target.rb +19 -23
- data/lib/servactory/version.rb +1 -1
- data/lib/servactory.rb +2 -0
- metadata +2 -47
- data/lib/servactory/stroma/dsl.rb +0 -118
- data/lib/servactory/stroma/entry.rb +0 -32
- data/lib/servactory/stroma/exceptions/base.rb +0 -45
- data/lib/servactory/stroma/exceptions/invalid_hook_type.rb +0 -29
- data/lib/servactory/stroma/exceptions/key_already_registered.rb +0 -32
- data/lib/servactory/stroma/exceptions/registry_frozen.rb +0 -33
- data/lib/servactory/stroma/exceptions/registry_not_finalized.rb +0 -33
- data/lib/servactory/stroma/exceptions/unknown_hook_target.rb +0 -39
- data/lib/servactory/stroma/hooks/applier.rb +0 -63
- data/lib/servactory/stroma/hooks/collection.rb +0 -103
- data/lib/servactory/stroma/hooks/factory.rb +0 -80
- data/lib/servactory/stroma/hooks/hook.rb +0 -74
- data/lib/servactory/stroma/registry.rb +0 -94
- data/lib/servactory/stroma/settings/collection.rb +0 -90
- data/lib/servactory/stroma/settings/registry_settings.rb +0 -88
- data/lib/servactory/stroma/settings/setting.rb +0 -113
- data/lib/servactory/stroma/state.rb +0 -59
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Servactory
|
|
4
|
-
module Stroma
|
|
5
|
-
module Settings
|
|
6
|
-
# Dynamic key-value storage for extension configuration.
|
|
7
|
-
#
|
|
8
|
-
# ## Purpose
|
|
9
|
-
#
|
|
10
|
-
# Provides a Hash-based container for storing extension-specific
|
|
11
|
-
# configuration data. Uses Forwardable delegation for consistent API.
|
|
12
|
-
# This is the leaf-level container in the settings hierarchy.
|
|
13
|
-
#
|
|
14
|
-
# ## Usage
|
|
15
|
-
#
|
|
16
|
-
# ```ruby
|
|
17
|
-
# setting = Servactory::Stroma::Settings::Setting.new
|
|
18
|
-
# setting[:method_name] = :authorize
|
|
19
|
-
# setting[:method_name] # => :authorize
|
|
20
|
-
# setting.key?(:method_name) # => true
|
|
21
|
-
# ```
|
|
22
|
-
#
|
|
23
|
-
# ## Integration
|
|
24
|
-
#
|
|
25
|
-
# Used by RegistrySettings to store individual extension settings.
|
|
26
|
-
# Properly duplicated during class inheritance via initialize_dup.
|
|
27
|
-
class Setting
|
|
28
|
-
extend Forwardable
|
|
29
|
-
|
|
30
|
-
# @!method [](key)
|
|
31
|
-
# Retrieves a value by key.
|
|
32
|
-
# @param key [Symbol] The key to look up
|
|
33
|
-
# @return [Object, nil] The stored value or nil
|
|
34
|
-
# @!method []=(key, value)
|
|
35
|
-
# Stores a value by key.
|
|
36
|
-
# @param key [Symbol] The key to store under
|
|
37
|
-
# @param value [Object] The value to store
|
|
38
|
-
# @!method key?(key)
|
|
39
|
-
# Checks if a key exists.
|
|
40
|
-
# @param key [Symbol] The key to check
|
|
41
|
-
# @return [Boolean] true if key exists
|
|
42
|
-
# @!method keys
|
|
43
|
-
# Returns all stored keys.
|
|
44
|
-
# @return [Array<Symbol>] List of keys
|
|
45
|
-
# @!method each
|
|
46
|
-
# Iterates over all key-value pairs.
|
|
47
|
-
# @yield [key, value] Each stored pair
|
|
48
|
-
# @!method empty?
|
|
49
|
-
# Checks if no values are stored.
|
|
50
|
-
# @return [Boolean] true if empty
|
|
51
|
-
# @!method size
|
|
52
|
-
# Returns the number of stored values.
|
|
53
|
-
# @return [Integer] Number of entries
|
|
54
|
-
# @!method map
|
|
55
|
-
# Maps over all key-value pairs.
|
|
56
|
-
# @yield [key, value] Each stored pair
|
|
57
|
-
# @return [Array] Mapped results
|
|
58
|
-
def_delegators :@data, :[], :[]=, :key?, :keys, :each, :empty?, :size, :map
|
|
59
|
-
|
|
60
|
-
# Creates a new setting container.
|
|
61
|
-
#
|
|
62
|
-
# @param data [Hash] Initial data (default: empty Hash)
|
|
63
|
-
def initialize(data = {})
|
|
64
|
-
@data = data
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Creates a deep copy during inheritance.
|
|
68
|
-
#
|
|
69
|
-
# @param original [Setting] The original setting being duplicated
|
|
70
|
-
# @return [void]
|
|
71
|
-
def initialize_dup(original)
|
|
72
|
-
super
|
|
73
|
-
@data = deep_dup(original.instance_variable_get(:@data))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Converts to a plain Hash.
|
|
77
|
-
#
|
|
78
|
-
# @return [Hash] Deep copy of internal data
|
|
79
|
-
def to_h
|
|
80
|
-
deep_dup(@data)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Fetches a value with optional default.
|
|
84
|
-
#
|
|
85
|
-
# @param key [Symbol] The key to fetch
|
|
86
|
-
# @param args [Array] Optional default value
|
|
87
|
-
# @yield Optional block for default value
|
|
88
|
-
# @return [Object] The fetched value or default
|
|
89
|
-
#
|
|
90
|
-
# @example
|
|
91
|
-
# setting.fetch(:method_name, :default_method)
|
|
92
|
-
# setting.fetch(:method_name) { :computed_default }
|
|
93
|
-
def fetch(key, *args, &block)
|
|
94
|
-
@data.fetch(key.to_sym, *args, &block)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
private
|
|
98
|
-
|
|
99
|
-
# Recursively duplicates nested Hash and Array structures.
|
|
100
|
-
#
|
|
101
|
-
# @param obj [Object] The object to duplicate
|
|
102
|
-
# @return [Object] Deep copy of the object
|
|
103
|
-
def deep_dup(obj)
|
|
104
|
-
case obj
|
|
105
|
-
when Hash then obj.transform_values { |v| deep_dup(v) }
|
|
106
|
-
when Array then obj.map { |v| deep_dup(v) }
|
|
107
|
-
else obj.respond_to?(:dup) ? obj.dup : obj
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Servactory
|
|
4
|
-
module Stroma
|
|
5
|
-
# Holds the complete Stroma state for a service class.
|
|
6
|
-
#
|
|
7
|
-
# ## Purpose
|
|
8
|
-
#
|
|
9
|
-
# Central container that stores:
|
|
10
|
-
# - Hooks collection for before/after extension points
|
|
11
|
-
# - Settings collection for extension-specific configuration
|
|
12
|
-
#
|
|
13
|
-
# Each service class has its own State instance, duplicated during
|
|
14
|
-
# inheritance to ensure independent configuration.
|
|
15
|
-
#
|
|
16
|
-
# ## Usage
|
|
17
|
-
#
|
|
18
|
-
# Accessed via `stroma` method in service classes:
|
|
19
|
-
#
|
|
20
|
-
# ```ruby
|
|
21
|
-
# class MyService < ApplicationService::Base
|
|
22
|
-
# # In ClassMethods:
|
|
23
|
-
# stroma.hooks.before(:actions)
|
|
24
|
-
# stroma.settings[:actions][:authorization][:method_name]
|
|
25
|
-
# end
|
|
26
|
-
# ```
|
|
27
|
-
#
|
|
28
|
-
# ## Integration
|
|
29
|
-
#
|
|
30
|
-
# Stored as @stroma instance variable on each service class.
|
|
31
|
-
# Duplicated in DSL.inherited to provide inheritance isolation.
|
|
32
|
-
class State
|
|
33
|
-
# @!attribute [r] hooks
|
|
34
|
-
# @return [Hooks::Collection] The hooks collection for this class
|
|
35
|
-
# @!attribute [r] settings
|
|
36
|
-
# @return [Settings::Collection] The settings collection for this class
|
|
37
|
-
attr_reader :hooks, :settings
|
|
38
|
-
|
|
39
|
-
# Creates a new State with empty collections.
|
|
40
|
-
def initialize
|
|
41
|
-
@hooks = Hooks::Collection.new
|
|
42
|
-
@settings = Settings::Collection.new
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Creates a deep copy during inheritance.
|
|
46
|
-
#
|
|
47
|
-
# Ensures child classes have independent hooks and settings
|
|
48
|
-
# that don't affect the parent class.
|
|
49
|
-
#
|
|
50
|
-
# @param original [State] The original state being duplicated
|
|
51
|
-
# @return [void]
|
|
52
|
-
def initialize_dup(original)
|
|
53
|
-
super
|
|
54
|
-
@hooks = original.instance_variable_get(:@hooks).dup
|
|
55
|
-
@settings = original.instance_variable_get(:@settings).dup
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|