Skip to content

Use initialize_copy instead of Marshal to get a deep clone of the Arel AST #97

@mvgijssel

Description

@mvgijssel

Currently

Marshal.load(Marshal.dump(object))

is used to get a deep clone of an Arel AST which is necessary when modifying the tree. Using Marshal feel like a hack to get a deep clone, Ruby's initialize_copy feels like a better solution to this problem.

To achieve this all Arel nodes need to implement initialize_copy when their instance variables contain a complex object, a non scalar like String or Integer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions