@@ -181,21 +181,21 @@ def add_relationship(name, relationship)
181181 self . relationships_to_serialize [ name ] = relationship
182182 end
183183
184- def has_many ( relationship_name , options = { } )
184+ def has_many ( relationship_name , options = { } , & block )
185185 name = relationship_name . to_sym
186- hash = create_relationship_hash ( relationship_name , :has_many , options )
186+ hash = create_relationship_hash ( relationship_name , :has_many , options , block )
187187 add_relationship ( name , hash )
188188 end
189189
190- def has_one ( relationship_name , options = { } )
190+ def has_one ( relationship_name , options = { } , & block )
191191 name = relationship_name . to_sym
192- hash = create_relationship_hash ( relationship_name , :has_one , options )
192+ hash = create_relationship_hash ( relationship_name , :has_one , options , block )
193193 add_relationship ( name , hash )
194194 end
195195
196196 alias belongs_to has_one
197197
198- def create_relationship_hash ( base_key , relationship_type , options )
198+ def create_relationship_hash ( base_key , relationship_type , options , block )
199199 name = base_key . to_sym
200200 if relationship_type == :has_many
201201 base_serialization_key = base_key . to_s . singularize
@@ -212,6 +212,7 @@ def create_relationship_hash(base_key, relationship_type, options)
212212 id_method_name : options [ :id_method_name ] || "#{ base_serialization_key } #{ id_postfix } " . to_sym ,
213213 record_type : options [ :record_type ] || run_key_transform ( base_key_sym ) ,
214214 object_method_name : options [ :object_method_name ] || name ,
215+ object_block : block ,
215216 serializer : compute_serializer_name ( options [ :serializer ] || base_key_sym ) ,
216217 relationship_type : relationship_type ,
217218 cached : options [ :cached ] || false ,
0 commit comments