mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Describe undesirable but necessary cruft
This commit is contained in:
parent
2130cdfc00
commit
f9117072fb
19
cruft.md
Normal file
19
cruft.md
Normal file
@ -0,0 +1,19 @@
|
||||
As of Ruby 1.9.3, it is impossible to dynamically generate a Symbol
|
||||
through interpolation without generating garbage. Theoretically, Ruby
|
||||
should be able to take care of this by building up the String in C and
|
||||
interning the C String.
|
||||
|
||||
Because of this, we avoid generating dynamic Symbols at runtime. For
|
||||
example, instead of generating the instrumentation event dynamically, we
|
||||
have a constant with a Hash of events:
|
||||
|
||||
```ruby
|
||||
INSTRUMENT = {
|
||||
:serialize => :"serialize.serializer",
|
||||
:associations => :"associations.serializer"
|
||||
}
|
||||
```
|
||||
|
||||
If Ruby ever fixes this issue and avoids generating garbage with dynamic
|
||||
symbols, this code can be removed.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user