@@ -14,6 +14,8 @@ module AssignedAttributes
1414 extend T ::Sig
1515 extend T ::Helpers
1616
17+ DEFAULT = Object . new
18+
1719 class << self
1820 extend T ::Sig
1921
@@ -43,14 +45,27 @@ module ClassMethods
4345 #: Module
4446 attr_reader :assigned_attributes_methods_module
4547
46- #: (String | Symbol name, Class type, ?collection: bool, ?default: Proc?, ?doc: String?, **untyped kwargs) ?{ -> void } -> void
47- def attribute ( name , type , collection : false , default : nil , doc : nil , **kwargs , &block )
48- super
48+ #: (
49+ #| String | Symbol name,
50+ #| Class shale_mapper,
51+ #| ?collection: bool,
52+ #| ?default: Proc?,
53+ #| **Object kwargs
54+ #| ) ?{ -> void } -> void
55+ def attribute (
56+ name ,
57+ shale_mapper ,
58+ collection : false ,
59+ default : -> { DEFAULT } ,
60+ **kwargs ,
61+ &block
62+ )
63+ super ( name , shale_mapper , collection :, default :, **kwargs , &block ) # rubocop:disable Style/SuperArguments
4964
5065 @assigned_attributes_methods_module . class_eval <<~RUBY , __FILE__ , __LINE__ + 1
5166 def #{ name } =(val)
67+ return if val.equal?(::Shale::Builder::AssignedAttributes::DEFAULT)
5268 super
53- return unless @__initialized
5469
5570 self.assigned_attribute_names << #{ name . to_sym . inspect }
5671 end
@@ -59,14 +74,6 @@ def #{name}=(val)
5974 end
6075 mixes_in_class_methods ClassMethods
6176
62- def initialize ( *args , **kwargs , &block )
63- super
64- @__initialized = true
65- end
66-
67- #: bool?
68- attr_reader :__initialized
69-
7077 # Returns a set of names of assigned shale attributes.
7178 #
7279 #: -> Set[Symbol]
0 commit comments