varvet / serial

Plain old Ruby for generating primitive data structures from object graphs.
107 stars 2 forks source link

Don't use `respond_to?(:map)` to distinguish enumerables. #8

Closed jnicklas closed 8 years ago

jnicklas commented 8 years ago

See: https://github.com/elabs/serial/blob/7ed2b07/lib/serial/rails_helpers.rb#L27

This is a bad idea, because some things might have #map methods without actually being enumerable. Consider:

class Marker
  belongs_to :map
end

Oops.