gpi-active_model_serializers 0.8.4.alpha4 → 0.8.4.alpha5
Sign up to get free protection for your applications and to get access to all the features.
@@ -428,34 +428,23 @@ module ActiveModel
|
|
428
428
|
# Returns a hash representation of the serializable
|
429
429
|
# object attributes.
|
430
430
|
def attributes
|
431
|
-
|
432
|
-
|
433
|
-
hash = _fast_attributes
|
431
|
+
_fast_attributes
|
434
432
|
rescue NameError
|
435
433
|
method = "def _fast_attributes\n"
|
436
434
|
|
437
435
|
method << " h = {}\n"
|
438
436
|
|
439
437
|
_attributes.each do |name,key|
|
440
|
-
method << "
|
438
|
+
method << " if include?(:\"#{name}\") && (!_hidden_attributes.include?(:\"#{name}\") || (@options.key?(:only) && Array(@options[:only]).include?(:\"#{name}\")))\n"
|
439
|
+
method << " h[:\"#{key}\"] = read_attribute_for_serialization(:\"#{name}\")\n"
|
440
|
+
method << " end\n"
|
441
441
|
end
|
442
442
|
method << " h\nend"
|
443
443
|
|
444
|
-
|
445
|
-
hash = _fast_attributes
|
446
|
-
|
447
|
-
puts "FAST ATTRIBUTES: #{hash}"
|
448
|
-
|
449
|
-
_hidden_attributes.each do |name|
|
450
|
-
explicitly_included = @options.key?(:only) && Array(@options[:only]).include?(name)
|
451
|
-
puts "HIDDEN ATTRIBUTE: #{name} INCLUDE?: #{explicitly_included}"
|
444
|
+
puts "METHOD: #{method}"
|
452
445
|
|
453
|
-
|
454
|
-
|
455
|
-
end
|
456
|
-
end
|
457
|
-
|
458
|
-
hash
|
446
|
+
self.class.class_eval method
|
447
|
+
_fast_attributes
|
459
448
|
end
|
460
449
|
|
461
450
|
# Returns options[:scope]
|