@@ -233,14 +233,11 @@ def nested_exposures
233
233
# the values are document keys in the entity's documentation key. When calling
234
234
# #docmentation, any exposure without a documentation key will be ignored.
235
235
def self . documentation
236
- @documentation ||= exposures . inject ( { } ) do |memo , ( attribute , exposure_options ) |
236
+ @documentation ||= exposures . each_with_object ( { } ) do |( attribute , exposure_options ) , memo |
237
237
unless exposure_options [ :documentation ] . nil? || exposure_options [ :documentation ] . empty?
238
238
memo [ key_for ( attribute ) ] = exposure_options [ :documentation ]
239
239
end
240
- memo
241
240
end
242
-
243
- @documentation
244
241
end
245
242
246
243
# This allows you to declare a Proc in which exposures can be formatted with.
@@ -468,7 +465,7 @@ def serializable_hash(runtime_options = {})
468
465
469
466
opts = options . merge ( runtime_options || { } )
470
467
471
- valid_exposures . inject ( { } ) do |output , ( attribute , exposure_options ) |
468
+ valid_exposures . each_with_object ( { } ) do |( attribute , exposure_options ) , output |
472
469
if should_return_attribute? ( attribute , opts ) && conditions_met? ( exposure_options , opts )
473
470
partial_output = value_for ( attribute , opts )
474
471
@@ -485,8 +482,6 @@ def serializable_hash(runtime_options = {})
485
482
partial_output
486
483
end
487
484
end
488
-
489
- output
490
485
end
491
486
end
492
487
@@ -498,7 +493,7 @@ def should_return_attribute?(attribute, options)
498
493
def only_fields ( options , for_attribute = nil )
499
494
return nil unless options [ :only ]
500
495
501
- @only_fields ||= options [ :only ] . inject ( { } ) do |allowed_fields , attribute |
496
+ @only_fields ||= options [ :only ] . each_with_object ( { } ) do |attribute , allowed_fields |
502
497
if attribute . is_a? ( Hash )
503
498
attribute . each do |attr , nested_attrs |
504
499
allowed_fields [ attr ] ||= [ ]
@@ -507,8 +502,6 @@ def only_fields(options, for_attribute = nil)
507
502
else
508
503
allowed_fields [ attribute ] = true
509
504
end
510
-
511
- allowed_fields
512
505
end
513
506
514
507
if for_attribute && @only_fields [ for_attribute ] . is_a? ( Array )
0 commit comments