File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ def requestor
167167 end
168168
169169 # Default attributes that every instance of this resource should be
170- # intialized with. Optionally, override this method in a subclass.
170+ # initialized with. Optionally, override this method in a subclass.
171171 #
172172 # @return [Hash] Default attributes
173173 def default_attributes
@@ -272,7 +272,7 @@ def _prefix_path
272272
273273 def _set_prefix_path ( attrs )
274274 paths = _belongs_to_associations . map do |a |
275- a . set_prefix_path ( attrs , route_formatter )
275+ a . set_prefix_path ( attrs , route_formatter )
276276 end
277277
278278 paths . join ( "/" )
@@ -305,7 +305,7 @@ def initialize(params = {})
305305 @persisted = nil
306306 self . links = self . class . linker . new ( params . delete ( "links" ) || { } )
307307 self . relationships = self . class . relationship_linker . new ( self . class , params . delete ( "relationships" ) || { } )
308- self . attributes = params . merge ( self . class . default_attributes )
308+ self . attributes = self . class . default_attributes . merge ( params )
309309
310310 self . class . schema . each_property do |property |
311311 attributes [ property . name ] = property . default unless attributes . has_key? ( property . name ) || property . default . nil?
Original file line number Diff line number Diff line change @@ -89,4 +89,10 @@ def test_associations_as_params
8989 assert_equal ( article . attributes [ 'author' ] [ 'type' ] , 'authors' )
9090 assert_equal ( article . attributes [ 'author' ] [ 'id' ] , 1 )
9191 end
92+
93+ def test_default_params_overrideable
94+ article = Article . new ( type : 'Story' )
95+ assert_equal ( article . type , 'Story' )
96+ end
97+
9298end
You can’t perform that action at this time.
0 commit comments