@@ -9,22 +9,7 @@ class Model
99 # Configuration to avoid a breaking change with older versions of this class which lacked defined attributes.
1010 # Previous behavior was: 1) initialized attributes were the
1111 class_attribute :attributes_are_always_the_initialization_data , instance_writer : false , instance_reader : false
12- self . attributes_are_always_the_initialization_data = false # remove this commit, just for demonstration
13- module AttributesAreAlwaysTheInitializationData
14- def initialize ( attributes = { } )
15- @initialized_attributes = attributes && attributes . symbolize_keys
16- super
17- end
18-
19- # Defaults to the downcased model name.
20- def id
21- @initialized_attributes . fetch ( :id ) { self . class . model_name . name && self . class . model_name . name . downcase }
22- end
23-
24- def attributes
25- @initialized_attributes
26- end
27- end
12+ self . attributes_are_always_the_initialization_data = true
2813
2914 def self . inherited ( subclass )
3015 if subclass . attributes_are_always_the_initialization_data
@@ -96,5 +81,21 @@ def self.lookup_ancestors
9681 [ self ]
9782 end
9883 # :nocov:
84+
85+ module AttributesAreAlwaysTheInitializationData
86+ def initialize ( attributes = { } )
87+ @initialized_attributes = attributes && attributes . symbolize_keys
88+ super
89+ end
90+
91+ # Defaults to the downcased model name.
92+ def id
93+ @initialized_attributes . fetch ( :id ) { self . class . model_name . name && self . class . model_name . name . downcase }
94+ end
95+
96+ def attributes
97+ @initialized_attributes
98+ end
99+ end
99100 end
100101end
0 commit comments