domainic-attributer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +11 -0
  3. data/CHANGELOG.md +32 -1
  4. data/README.md +42 -355
  5. data/docs/USAGE.md +723 -0
  6. data/lib/domainic/attributer/attribute/callback.rb +21 -9
  7. data/lib/domainic/attributer/attribute/coercer.rb +28 -13
  8. data/lib/domainic/attributer/attribute/mixin/belongs_to_attribute.rb +16 -13
  9. data/lib/domainic/attributer/attribute/signature.rb +43 -32
  10. data/lib/domainic/attributer/attribute/validator.rb +46 -16
  11. data/lib/domainic/attributer/attribute.rb +28 -18
  12. data/lib/domainic/attributer/attribute_set.rb +21 -19
  13. data/lib/domainic/attributer/class_methods.rb +136 -83
  14. data/lib/domainic/attributer/dsl/attribute_builder/option_parser.rb +64 -22
  15. data/lib/domainic/attributer/dsl/attribute_builder.rb +515 -26
  16. data/lib/domainic/attributer/dsl/initializer.rb +23 -18
  17. data/lib/domainic/attributer/dsl/method_injector.rb +16 -14
  18. data/lib/domainic/attributer/errors/aggregate_error.rb +36 -0
  19. data/lib/domainic/attributer/errors/callback_execution_error.rb +30 -0
  20. data/lib/domainic/attributer/errors/coercion_execution_error.rb +37 -0
  21. data/lib/domainic/attributer/errors/error.rb +19 -0
  22. data/lib/domainic/attributer/errors/validation_execution_error.rb +30 -0
  23. data/lib/domainic/attributer/instance_methods.rb +11 -8
  24. data/lib/domainic/attributer/undefined.rb +9 -7
  25. data/lib/domainic/attributer.rb +88 -27
  26. data/sig/domainic/attributer/attribute/callback.rbs +10 -7
  27. data/sig/domainic/attributer/attribute/coercer.rbs +14 -11
  28. data/sig/domainic/attributer/attribute/mixin/belongs_to_attribute.rbs +14 -12
  29. data/sig/domainic/attributer/attribute/signature.rbs +43 -32
  30. data/sig/domainic/attributer/attribute/validator.rbs +28 -13
  31. data/sig/domainic/attributer/attribute.rbs +27 -17
  32. data/sig/domainic/attributer/attribute_set.rbs +21 -19
  33. data/sig/domainic/attributer/class_methods.rbs +133 -80
  34. data/sig/domainic/attributer/dsl/attribute_builder/option_parser.rbs +62 -22
  35. data/sig/domainic/attributer/dsl/attribute_builder.rbs +515 -26
  36. data/sig/domainic/attributer/dsl/initializer.rbs +21 -19
  37. data/sig/domainic/attributer/dsl/method_injector.rbs +16 -14
  38. data/sig/domainic/attributer/errors/aggregate_error.rbs +28 -0
  39. data/sig/domainic/attributer/errors/callback_execution_error.rbs +23 -0
  40. data/sig/domainic/attributer/errors/coercion_execution_error.rbs +29 -0
  41. data/sig/domainic/attributer/errors/error.rbs +17 -0
  42. data/sig/domainic/attributer/errors/validation_execution_error.rbs +23 -0
  43. data/sig/domainic/attributer/instance_methods.rbs +11 -8
  44. data/sig/domainic/attributer/undefined.rbs +5 -3
  45. data/sig/domainic/attributer.rbs +88 -27
  46. metadata +19 -6
@@ -1,12 +1,14 @@
1
1
  module Domainic
2
2
  module Attributer
3
3
  class Attribute
4
- # A class responsible for managing change callbacks for an attribute.
4
+ # A class responsible for managing change callbacks for an attribute
5
5
  #
6
6
  # This class handles the execution of callbacks that are triggered when an
7
7
  # attribute's value changes. Each callback must be a Proc that accepts two
8
- # arguments: the old value and the new value.
8
+ # arguments: the old value, and the new value
9
9
  #
10
+ # @api private
11
+ # @!visibility private
10
12
  # @author {https://aaronmallen.me Aaron Allen}
11
13
  # @since 0.1.0
12
14
  class Callback
@@ -16,26 +18,27 @@ module Domainic
16
18
 
17
19
  include BelongsToAttribute
18
20
 
19
- # Initialize a new Callback instance.
21
+ # Initialize a new Callback instance
20
22
  #
21
- # @param attribute [Attribute] the attribute this Callback belongs to
23
+ # @param attribute [Attribute] the {Attribute} this instance belongs to
22
24
  # @param handlers [Array<Proc>] the handlers to use for processing
23
25
  #
24
- # @return [Callback] the new instance of Callback
26
+ # @return [Callback] the new Callback instance
25
27
  def initialize: (Attribute attribute, Array[handler] | handler handlers) -> void
26
28
 
27
- # Execute all callbacks for a value change.
29
+ # Execute all callbacks for a value change
28
30
  #
29
31
  # @param instance [Object] the instance on which to execute callbacks
30
32
  # @param old_value [Object] the previous value
31
33
  # @param new_value [Object] the new value
32
34
  #
35
+ # @raise [CallbackExecutionError] if any callback handlers raises an error
33
36
  # @return [void]
34
37
  def call: (untyped instance, untyped old_value, untyped new_value) -> void
35
38
 
36
39
  private
37
40
 
38
- # Validate that a callback handler is a valid Proc.
41
+ # Validate that a callback handler is a valid Proc
39
42
  #
40
43
  # @param handler [Object] the handler to validate
41
44
  #
@@ -1,12 +1,14 @@
1
1
  module Domainic
2
2
  module Attributer
3
3
  class Attribute
4
- # A class responsible for coercing attribute values.
4
+ # A class responsible for coercing attribute values
5
5
  #
6
6
  # This class manages the coercion of values assigned to an attribute. Coercion can be
7
- # handled by either a Proc that accepts a single value argument, or by referencing an
8
- # instance method via Symbol.
7
+ # handled by either a {Proc} that accepts a single value argument, or by referencing an
8
+ # instance method via {Symbol}
9
9
  #
10
+ # @api private
11
+ # @!visibility private
10
12
  # @author {https://aaronmallen.me Aaron Allen}
11
13
  # @since 0.1.0
12
14
  class Coercer
@@ -18,25 +20,26 @@ module Domainic
18
20
 
19
21
  @handlers: Array[handler]
20
22
 
21
- # Initialize a new Coercer instance.
23
+ # Initialize a new {Coercer} instance
22
24
  #
23
- # @param attribute [Attribute] the attribute this Coercer belongs to
25
+ # @param attribute [Attribute] the {Attribute} this instance belongs to
24
26
  # @param handlers [Array<Proc, Symbol>] the handlers to use for processing
25
27
  #
26
- # @return [Coercer] the new instance of Coercer
28
+ # @return [Coercer] the new Coercer instance
27
29
  def initialize: (Attribute attribute, Array[handler] | handler handlers) -> void
28
30
 
29
- # Process a value through all coercion handlers.
31
+ # Process a value through all coercion handlers
30
32
  #
31
33
  # @param instance [Object] the instance on which to perform coercion
32
34
  # @param value [Object] the value to coerce
33
35
  #
34
- # @return [Object] the coerced value
35
- def call: (untyped instance, untyped value) -> untyped
36
+ # @raise [CoercionExecutionError] if a coercion handler raises an error
37
+ # @return [Object, nil] the coerced value
38
+ def call: (untyped instance, untyped? value) -> untyped?
36
39
 
37
40
  private
38
41
 
39
- # Process a value through a single coercion handler.
42
+ # Process a value through a single coercion handler
40
43
  #
41
44
  # @param instance [Object] the instance on which to perform coercion
42
45
  # @param handler [Proc, Symbol] the coercion handler
@@ -46,7 +49,7 @@ module Domainic
46
49
  # @return [Object] the coerced value
47
50
  def coerce_value: (untyped instance, handler, untyped value) -> untyped
48
51
 
49
- # Validate that a coercion handler is valid.
52
+ # Validate that a coercion handler is valid
50
53
  #
51
54
  # @param handler [Object] the handler to validate
52
55
  #
@@ -1,43 +1,45 @@
1
1
  module Domainic
2
2
  module Attributer
3
3
  class Attribute
4
- # A mixin providing common functionality for classes that belong to an Attribute.
4
+ # A mixin providing common functionality for classes that belong to an Attribute
5
5
  #
6
6
  # This module provides initialization and duplication behavior for classes that are owned
7
7
  # by and work in conjunction with an Attribute instance. These classes typically handle
8
- # specific aspects of attribute processing such as coercion, validation, or callbacks.
8
+ # specific aspects of attribute processing such as coercion, validation, or callbacks
9
9
  #
10
+ # @api private
11
+ # @!visibility private
10
12
  # @author {https://aaronmallen.me Aaron Allen}
11
13
  # @since 0.1.0
12
14
  module BelongsToAttribute
13
15
  @attribute: Attribute
14
16
 
15
- # Initialize a new instance that belongs to an attribute.
17
+ # Initialize a new instance that belongs to an {Attribute}
16
18
  #
17
- # @param attribute [Attribute] the attribute this instance belongs to
19
+ # @param attribute [Attribute] the {Attribute} this instance belongs to
18
20
  #
19
- # @return [void]
21
+ # @return [BelongsToAttribute] the new BelongsToAttribute instance
20
22
  def initialize: (Attribute attribute, *untyped, **untyped) -> void
21
23
 
22
- # Create a duplicate instance associated with a new attribute.
24
+ # Create a duplicate instance associated with a new {Attribute}
23
25
  #
24
26
  # @param new_attribute [Attribute] the new attribute to associate with
25
27
  #
26
- # @return [BelongsToAttribute] a duplicate instance
28
+ # @return [BelongsToAttribute] duplicate instance with new {Attribute}
27
29
  def dup_with_attribute: (Attribute attribute) -> BelongsToAttribute
28
30
 
29
31
  private
30
32
 
31
- # Generate a method name for error messages.
33
+ # Generate a method name for error messages
32
34
  #
33
- # @return [String] the formatted method name
35
+ # @return [String] formatted method name
34
36
  def attribute_method_name: () -> String
35
37
 
36
- # Ensure that an attribute is a valid {Attribute} instance.
38
+ # Ensure that an {Attribute} is a valid {Attribute} instance
37
39
  #
38
- # @param attribute [Attribute] the attribute to validate
40
+ # @param attribute [Attribute] the {Attribute} to validate
39
41
  #
40
- # @raise [TypeError] if the attribute is not a valid {Attribute} instance
42
+ # @raise [TypeError] if the attribute is not a valid Attribute instance
41
43
  # @return [void]
42
44
  def validate_attribute!: (Attribute attribute) -> void
43
45
  end
@@ -1,12 +1,14 @@
1
1
  module Domainic
2
2
  module Attributer
3
3
  class Attribute
4
- # A class responsible for managing attribute signature information.
4
+ # A class responsible for managing attribute signature information
5
5
  #
6
- # This class encapsulates the type and visibility configuration for an attribute.
6
+ # This class encapsulates the type and visibility configuration for an {Attribute}
7
7
  # It validates and manages whether an attribute is an argument or option, as well
8
- # as controlling read and write visibility (public, protected, or private).
8
+ # as controlling read and write visibility (public, protected, or private)
9
9
  #
10
+ # @api private
11
+ # @!visibility private
10
12
  # @author {https://aaronmallen.me Aaron Allen}
11
13
  # @since 0.1.0
12
14
  class Signature
@@ -20,10 +22,10 @@ module Domainic
20
22
 
21
23
  include BelongsToAttribute
22
24
 
23
- # @return [Hash{Symbol => Object}] Default options for a new Signature instance.
25
+ # @return [Hash{Symbol => Object}] Default options for a new Signature instance
24
26
  DEFAULT_OPTIONS: default_options
25
27
 
26
- # Constants defining valid attribute types.
28
+ # Constants defining valid attribute types
27
29
  #
28
30
  # @author {https://aaronmallen.me Aaron Allen}
29
31
  # @since 0.1.0
@@ -38,7 +40,7 @@ module Domainic
38
40
  ALL: Array[type_symbol]
39
41
  end
40
42
 
41
- # Constants defining valid visibility levels.
43
+ # Constants defining valid visibility levels
42
44
  #
43
45
  # @author {https://aaronmallen.me Aaron Allen}
44
46
  # @since 0.1.0
@@ -68,110 +70,119 @@ module Domainic
68
70
 
69
71
  @type: type_symbol
70
72
 
73
+ # Get the position of the attribute
74
+ #
71
75
  # @return [Integer, nil] the position of the attribute
72
76
  attr_reader position: Integer?
73
77
 
78
+ # Get the visibility level for reading the attribute
79
+ #
74
80
  # @return [Symbol] the visibility level for reading the attribute
75
81
  attr_reader read_visibility: visibility_symbol
76
82
 
83
+ # Get the attribute type
84
+ #
77
85
  # @return [Symbol] the type of the attribute
78
86
  attr_reader type: type_symbol
79
87
 
88
+ # Get the visibility level for writing the attribute
89
+ #
80
90
  # @return [Symbol] the visibility level for writing the attribute
81
91
  attr_reader write_visibility: visibility_symbol
82
92
 
83
- # Initialize a new Signature instance.
93
+ # Initialize a new {Signature} instance
84
94
  #
85
- # @param attribute [Attribute] the attribute this signature belongs to
95
+ # @param attribute [Attribute] the {Attribute} this instance belongs to
86
96
  # @param options [Hash{Symbol => Object}] the signature options
87
- # @option options [Boolean] nilable (true) whether the attribute is allowed to be nil.
97
+ # @option options [Boolean] nilable (true) whether the attribute is allowed to be nil
88
98
  # @option options [Integer, nil] position (nil) optional position for ordered attributes
89
99
  # @option options [Symbol] read (:public) the read visibility
90
100
  # @option options [Boolean] required (false) whether the attribute is required
91
101
  # @option options [Symbol] type the type of attribute
92
102
  # @option options [Symbol] write (:public) the write visibility
93
103
  #
94
- # @return [void]
104
+ # @raise [ArgumentError] if the configuration is invalid
105
+ # @return [Signature] the new Signature instance
95
106
  def initialize: (Attribute attribute, type: type_symbol, ?nilable: bool, ?position: Integer?, ?read: visibility_symbol, ?required: bool, ?write: visibility_symbol) -> void
96
107
 
97
- # Check if this signature is for an argument attribute.
108
+ # Check if this signature is for an argument attribute
98
109
  #
99
110
  # @return [Boolean] true if this is an argument attribute
100
111
  def argument?: () -> bool
101
112
 
102
- # Check if the attribute is allowed to be nil.
113
+ # Check if the attribute allows nil values
103
114
  #
104
- # @return [Boolean] true if the attribute is allowed to be nil
115
+ # @return [Boolean] true if the attribute allows nil values
105
116
  def nilable?: () -> bool
106
117
 
107
- # Check if this signature is for an option attribute.
118
+ # Check if this signature is for an option attribute
108
119
  #
109
120
  # @return [Boolean] true if this is an option attribute
110
121
  def option?: () -> bool
111
122
 
112
- # Check if this signature is for an optional attribute.
123
+ # Check if this signature is for an optional attribute
113
124
  #
114
125
  # @return [Boolean] true if this is an optional attribute
115
126
  def optional?: () -> bool
116
127
 
117
- # Check if both read and write operations are private.
128
+ # Check if both read and write operations are private
118
129
  #
119
130
  # @return [Boolean] true if both read and write are private
120
131
  def private?: () -> bool
121
132
 
122
- # Check if read operations are private.
133
+ # Check if read operations are private
123
134
  #
124
135
  # @return [Boolean] true if read operations are private
125
136
  def private_read?: () -> bool
126
137
 
127
- # Check if write operations are private.
138
+ # Check if write operations are private
128
139
  #
129
140
  # @return [Boolean] true if write operations are private
130
141
  def private_write?: () -> bool
131
142
 
132
- # Check if both read and write operations are protected.
143
+ # Check if both read and write operations are protected
133
144
  #
134
145
  # @return [Boolean] true if both read and write are protected
135
146
  def protected?: () -> bool
136
147
 
137
- # Check if read operations are protected.
148
+ # Check if read operations are protected
138
149
  #
139
150
  # @return [Boolean] true if read operations are protected
140
151
  def protected_read?: () -> bool
141
152
 
142
- # Check if write operations are protected.
153
+ # Check if write operations are protected
143
154
  #
144
155
  # @return [Boolean] true if write operations are protected
145
156
  def protected_write?: () -> bool
146
157
 
147
- # Check if both read and write operations are public.
158
+ # Check if both read and write operations are public
148
159
  #
149
160
  # @return [Boolean] true if both read and write are public
150
161
  def public?: () -> bool
151
162
 
152
- # Check if read operations are public.
163
+ # Check if read operations are public
153
164
  #
154
165
  # @return [Boolean] true if read operations are public
155
166
  def public_read?: () -> bool
156
167
 
157
- # Check if write operations are public.
168
+ # Check if write operations are public
158
169
  #
159
170
  # @return [Boolean] true if write operations are public
160
171
  def public_write?: () -> bool
161
172
 
162
- # Check if the attribute is required.
173
+ # Check if this signature requires an attribute value
163
174
  #
164
- # @return [Boolean] true if the attribute is required
175
+ # @return [Boolean] true if this signature requires an attribute value
165
176
  def required?: () -> bool
166
177
 
167
178
  private
168
179
 
169
- # Get signature options as a hash.
180
+ # Get signature options as a hash
170
181
  #
171
182
  # @return [Hash] the signature options
172
183
  def to_options: () -> initialize_options
173
184
 
174
- # Validate that a value is a Boolean.
185
+ # Validate that a value is a boolean
175
186
  #
176
187
  # @param name [String, Symbol] the name of the attribute being validated
177
188
  # @param value [Boolean] the value to validate
@@ -180,7 +191,7 @@ module Domainic
180
191
  # @return [void]
181
192
  def validate_boolean!: (String | Symbol name, bool value) -> void
182
193
 
183
- # Validate all initialization options.
194
+ # Validate all initialization options
184
195
  #
185
196
  # @param options [Hash{Symbol => Object}] the options to validate
186
197
  # @option options [Boolean] nilable the nilable flag to validate
@@ -193,7 +204,7 @@ module Domainic
193
204
  # @return [void]
194
205
  def validate_initialize_options!: (Hash[Symbol, untyped] options) -> void
195
206
 
196
- # Validate that a position value is valid.
207
+ # Validate that a position value is valid
197
208
  #
198
209
  # @param position [Integer, nil] the position to validate
199
210
  #
@@ -201,7 +212,7 @@ module Domainic
201
212
  # @return [void]
202
213
  def validate_position!: (Integer? position) -> void
203
214
 
204
- # Validate that a type value is valid.
215
+ # Validate that a type value is valid
205
216
  #
206
217
  # @param type [Symbol] the type to validate
207
218
  #
@@ -209,7 +220,7 @@ module Domainic
209
220
  # @return [void]
210
221
  def validate_type!: (type_symbol type) -> void
211
222
 
212
- # Validate that visibility values are valid.
223
+ # Validate that visibility values are valid
213
224
  #
214
225
  # @param type [Symbol] which visibility setting to validate
215
226
  # @param value [Symbol] the visibility value to validate
@@ -1,12 +1,14 @@
1
1
  module Domainic
2
2
  module Attributer
3
3
  class Attribute
4
- # A class responsible for validating attribute values.
4
+ # A class responsible for validating attribute values
5
5
  #
6
6
  # This class manages the validation of values assigned to an attribute. Validation
7
- # can be performed either by a Proc that accepts a single value argument and returns
8
- # a boolean, or by any object that responds to the `===` operator.
7
+ # can be performed either by a {Proc} that accepts a single value argument and returns
8
+ # a boolean, or by any object that responds to the `===` operator
9
9
  #
10
+ # @api private
11
+ # @!visibility private
10
12
  # @author {https://aaronmallen.me Aaron Allen}
11
13
  # @since 0.1.0
12
14
  class Validator
@@ -32,38 +34,49 @@ module Domainic
32
34
 
33
35
  @handlers: Array[handler]
34
36
 
35
- # Initialize a new Validator instance.
37
+ # Initialize a new Validator instance
36
38
  #
37
- # @param attribute [Attribute] the attribute this Validator belongs to
39
+ # @param attribute [Attribute] the {Attribute} this instance belongs to
38
40
  # @param handlers [Array<Class, Module, Object, Proc>] the handlers to use for processing
39
41
  #
40
- # @return [Validator] the new instance of Validator
42
+ # @return [Validator] the new Validator instance
41
43
  def initialize: (Attribute attribute, Array[handler] | handler handlers) -> void
42
44
 
43
- # Validate a value using all configured validators.
45
+ # Validate a value using all configured validators
44
46
  #
45
47
  # @param instance [Object] the instance on which to perform validation
46
48
  # @param value [Object] the value to validate
47
49
  #
48
50
  # @raise [ArgumentError] if the value fails validation
51
+ # @raise [ValidationExecutionError] if errors occur during validation execution
49
52
  # @return [void]
50
53
  def call: (untyped instance, untyped value) -> void
51
54
 
52
55
  private
53
56
 
54
- # Handle a `nil` value.
57
+ # Handle a nil value
55
58
  #
56
59
  # @raise [ArgumentError] if the attribute is not nilable
57
- # @return [true] if the attribute is nilable
60
+ # @return [Boolean] true if the attribute is nilable
58
61
  def handle_nil!: () -> bool
59
62
 
60
- # Handle an {Undefined} value.
63
+ # Handle an {Undefined} value
61
64
  #
62
65
  # @raise [ArgumentError] if the attribute is required
63
- # @return [true] if the attribute is optional
66
+ # @return [Boolean] true if the attribute is optional
64
67
  def handle_undefined!: () -> bool
65
68
 
66
- # Validate that a validation handler is valid.
69
+ # Run all configured validations
70
+ #
71
+ # @param instance [Object] the instance on which to perform validation
72
+ # @param value [Object] the value to validate
73
+ #
74
+ # @raise [ArgumentError] if the value fails validation
75
+ # @raise [ValidationExecutionError] if errors occur during validation execution
76
+ # @return [void]
77
+ def run_validations!: (untyped instance, untyped value) -> void
78
+
79
+ # Validate that a validation handler is valid
67
80
  #
68
81
  # @param handler [Object] the handler to validate
69
82
  #
@@ -71,11 +84,13 @@ module Domainic
71
84
  # @return [void]
72
85
  def validate_handler!: (handler handler) -> void
73
86
 
74
- # Validate a value using a single handler.
87
+ # Validate a value using a single handler
75
88
  #
76
89
  # @param handler [Object] the handler to use for validation
77
90
  # @param instance [Object] the instance on which to perform validation
78
91
  # @param value [Object] the value to validate
92
+ #
93
+ # @return [Boolean] true if validation succeeds
79
94
  def validate_value!: (handler handler, untyped instance, untyped value) -> bool
80
95
  end
81
96
  end
@@ -1,12 +1,14 @@
1
1
  module Domainic
2
2
  module Attributer
3
- # A class representing a managed attribute in the Domainic::Attributer system.
3
+ # A class representing a managed attribute in the {Domainic::Attributer} system
4
4
  #
5
5
  # This class serves as the core component of the attribute management system.
6
6
  # It coordinates type information, visibility settings, value coercion,
7
7
  # validation, and change notifications for an attribute. Each instance
8
- # represents a single attribute definition within a class.
8
+ # represents a single attribute definition within a class
9
9
  #
10
+ # @api private
11
+ # @!visibility private
10
12
  # @author {https://aaronmallen.me Aaron Allen}
11
13
  # @since 0.1.0
12
14
  class Attribute
@@ -28,22 +30,30 @@ module Domainic
28
30
 
29
31
  @base: __todo__
30
32
 
33
+ # Get the class or module this attribute belongs to
34
+ #
31
35
  # @return [Class, Module] the class or module this attribute belongs to
32
36
  attr_reader base: __todo__
33
37
 
38
+ # Get the description of the attribute
39
+ #
34
40
  # @return [String, nil] the description of the attribute
35
41
  attr_reader description: String?
36
42
 
43
+ # Get the name of the attribute
44
+ #
37
45
  # @return [Symbol] the name of the attribute
38
46
  attr_reader name: Symbol
39
47
 
48
+ # Get the signature configuration for this attribute
49
+ #
40
50
  # @return [Signature] the signature configuration for this attribute
41
51
  attr_reader signature: Signature
42
52
 
43
- # Initialize a new Attribute instance.
53
+ # Initialize a new {Attribute} instance
44
54
  #
45
55
  # @param base [Class, Module] the class or module this attribute belongs to
46
- # @param options [Hash] the options to create the attribute with
56
+ # @param options [Hash{Symbol => Object}] the options to create the attribute with
47
57
  # @option options [Array<Proc>, Proc] :callbacks callbacks to trigger on value changes
48
58
  # @option options [Array<Proc, Symbol>, Proc, Symbol] :coercers handlers for value coercion
49
59
  # @option options [Object] :default the default value or generator
@@ -58,11 +68,10 @@ module Domainic
58
68
  # @option options [Symbol] :write the write visibility
59
69
  #
60
70
  # @raise [ArgumentError] if the configuration is invalid
61
- # @return [void]
62
- #
71
+ # @return [Attribute] the new Attribute instance
63
72
  def initialize: (__todo__ base, name: String | Symbol, type: Signature::type_symbol, ?callbacks: Array[Callback::handler] | Callback::handler, ?coercers: Array[Coercer::handler] | Coercer::handler, ?default: untyped, ?description: String?, ?nilable: bool, ?position: Integer?, ?read: Signature::visibility_symbol, ?required: bool, ?validators: Array[Validator::handler] | Validator::handler, ?write: Signature::visibility_symbol) -> void
64
73
 
65
- # Apply a value to the attribute on an instance.
74
+ # Apply a value to the attribute on an instance
66
75
  #
67
76
  # This method applies all attribute constraints (coercion, validation) to a value
68
77
  # and sets it on the given instance. It manages the complete lifecycle of setting
@@ -80,36 +89,37 @@ module Domainic
80
89
  # @return [void]
81
90
  def apply!: (untyped instance, untyped value) -> void
82
91
 
83
- # Check if this attribute has a default value.
92
+ # Check if this attribute has a default value
84
93
  #
85
94
  # @return [Boolean] true if a default value is set
86
95
  def default?: () -> bool
87
96
 
88
- # Create a duplicate instance for a new base class.
97
+ # Create a duplicate instance for a new base class
89
98
  #
90
99
  # @param new_base [Class, Module] the new base class
91
100
  #
101
+ # @raise [ArgumentError] if the new base is invalid
92
102
  # @return [Attribute] the duplicated instance
93
103
  def dup_with_base: (__todo__ new_base) -> Attribute
94
104
 
95
- # Generate the default value for this attribute.
105
+ # Generate the default value for this attribute
96
106
  #
97
107
  # @param instance [Object] the instance to generate the default for
98
108
  #
99
109
  # @return [Object] the generated default value
100
110
  def generate_default: (untyped instance) -> untyped
101
111
 
102
- # Merge this attribute's configuration with another.
112
+ # Merge this attribute's configuration with another
103
113
  #
104
114
  # @param other [Attribute] the attribute to merge with
105
115
  #
106
- # @raise [ArgumentError] if other is not an Attribute
116
+ # @raise [ArgumentError] if other is not an {Attribute}
107
117
  # @return [Attribute] a new attribute with merged configuration
108
118
  def merge: (Attribute other) -> Attribute
109
119
 
110
120
  private
111
121
 
112
- # Apply initialization options to create attribute components.
122
+ # Apply initialization options to create attribute components
113
123
  #
114
124
  # @param base [Class, Module] the base class
115
125
  # @param options [Hash] the initialization options
@@ -117,19 +127,19 @@ module Domainic
117
127
  # @return [void]
118
128
  def apply_initialize_options!: (__todo__ base, initialize_options options) -> void
119
129
 
120
- # Initialize a copy of this attribute.
130
+ # Initialize a copy of this attribute
121
131
  #
122
132
  # @param source [Attribute] the source attribute
123
133
  #
124
134
  # @return [Attribute] the initialized copy
125
135
  def initialize_copy: ...
126
136
 
127
- # Get this attribute's configuration as options.
137
+ # Get this attribute's configuration as options
128
138
  #
129
139
  # @return [Hash] the configuration options
130
140
  def to_options: () -> initialize_options
131
141
 
132
- # Validate and apply initialization options.
142
+ # Validate and apply initialization options
133
143
  #
134
144
  # @param base [Class, Module] the base class
135
145
  # @param options [Hash] the initialization options
@@ -137,7 +147,7 @@ module Domainic
137
147
  # @return [void]
138
148
  def validate_and_apply_initialize_options!: (__todo__ base, initialize_options options) -> void
139
149
 
140
- # Validate initialization options.
150
+ # Validate initialization options
141
151
  #
142
152
  # @param base [Class, Module] the base class
143
153
  # @param options [Hash] the initialization options