Skip to content

obj_extract should treat ActiveRecord::Associations::CollectionProxy as an Array #119

@jrochkind

Description

@jrochkind

Right now it doesn't, so you need to explicitly put to_a into your obj_extract paths, to turn it into an array.

One way to accomplish this would be to treat anything that respond_to?(:to_ary) as an array, rather than hard-coding ActiveRecord::Associations::CollectionProxy. Note that's to_ary not to_a, and thus should work fine, only things that really are meant to be interchangeable with Array should have to_ary.

I think this is a definite improvement... but ti's a backward incompatibility, since anything doing an explicit to_a will break.

Could be done with an obj_extract2 or something to be backwards compat. I dunno.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions