solnic / coercible

Powerful, flexible and configurable coercion library. And nothing more.
MIT License
137 stars 16 forks source link

Add Object#to_symbol coercion #20

Closed p-lambert closed 9 years ago

p-lambert commented 9 years ago

I have just came across a problem in which I need to coerce an Object subclass into a Symbol. Is there any reason for not having a #to_symbol coerce method?

Thank you!

p-lambert commented 9 years ago

Any thoughts on this?

solnic commented 9 years ago

Sorry I can't accept this. Other ruby objects don't have this kind of a coercion and I don't think it's a good idea to introduce this in coercible. A string can be easily symbolized but anything else is not, assuming that you want name of an object's class as a symbol would be very library-specific.