hzamani / acts_as_relation

Multi table Inheritance for rails
http://hzamani.github.com/acts_as_relation/
MIT License
180 stars 58 forks source link

Implement compatibility with the active_enum gem #68

Open lowjoel opened 10 years ago

lowjoel commented 10 years ago

This implements some compatibility with Active Enum.

The code probably isn't as clean as it can be; let me know how to improve. Thanks!

coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.81%) when pulling ef7bf66cd902bf0b8e2b15c4b54e68c39df8b77a on lowjoel:lowjoel-active_enum-compat into 476e02ef86a10ce4cfc741ba3b0725e4b184644a on hzamani:master.

lowjoel commented 10 years ago

Hello @hzamani, I have a bunch of fixes like these, where certain ActiveRecord methods are used by other gems. I'd like to ensure compatibility with those gems, but mixing them in the acts_as_relation gems seems nasty. Any ideas how we can support this use-case while not polluting our own gem? They're all merged in my master branch.

Case in point: I have another branch that implements some compatibility for Simple Form's form field deduction when a field is inherited from the superclass.

coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.81%) when pulling 4a6992faf30156b20320a5d61047f6508efa8b7d on lowjoel:lowjoel-active_enum-compat into 476e02ef86a10ce4cfc741ba3b0725e4b184644a on hzamani:master.

hzamani commented 10 years ago

Best way seems to have a 'acts-as-relation-compatibility' gem and add compatibility features there. However it don't seem to be a good idea to merge these features here, isn't it?

lowjoel commented 10 years ago

I think it doesn't make sense, yes. But at this point there isn't enough extension points that the gem can hook into. Any way to factor out the calls in the main gem so that other gems can add methods to be run either via alias_method or by overriding?

coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.81%) when pulling 7df18588239939a358f4dde91e7d90e9b99fc054 on lowjoel:lowjoel-active_enum-compat into 3b51a28b668f4404f3d199616a87494b2d38cb74 on hzamani:master.

lowjoel commented 10 years ago

@hzamani I've factored out the call such that everything is in define_acts_as_forwarders. Currently I've not pulled out the active_enum code yet, but my idea is that we can let gems interoperate with acts_as_relation by overriding define_acts_as_forwarders using alias_method_chain.

Do you think this is okay?

coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.36%) when pulling dcac4d60b1e6ab752655f55b00b05a02ddbff9e6 on lowjoel:lowjoel-active_enum-compat into 3b51a28b668f4404f3d199616a87494b2d38cb74 on hzamani:master.

coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.36%) when pulling dcac4d60b1e6ab752655f55b00b05a02ddbff9e6 on lowjoel:lowjoel-active_enum-compat into 3b51a28b668f4404f3d199616a87494b2d38cb74 on hzamani:master.

coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.36%) when pulling d93a6e774c9a5a47d0cb587e8288bb2c205ee172 on lowjoel:lowjoel-active_enum-compat into 3b51a28b668f4404f3d199616a87494b2d38cb74 on hzamani:master.