Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

include improvement to not clutter ActiveRecord::Base with Authlogic::ActsAsAuthentic methods #66

Closed
madarche opened this Issue Nov 12, 2009 · 3 comments

Comments

Projects
None yet
2 participants

At the time of this writing authlogic/acts_as_authentic/base.rb does inclusion of many methods in ActiveRecord::Base.

Would it be possible to improve this part to not include those methods in all objects inheriting from ActiveRecord::Base since it compromises code stability?

Here is a patch:

--- authlogic/acts_as_authentic/base.rb.orig 2009-11-12 17:48:58.000000000 +0100
+++ authlogic/acts_as_authentic/base.rb 2009-11-12 17:51:23.000000000 +0100
@@ -6,6 +6,17 @@
klass.class_eval do
extend Config
end

  •    klass.send :include, Authlogic::ActsAsAuthentic::Email
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::LoggedInStatus
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::Login
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::MagicColumns
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::Password
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::PerishableToken
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::PersistenceToken
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::RestfulAuthentication
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::SessionMaintenance
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::SingleAccessToken
    
  •    klass.send :include, Authlogic::ActsAsAuthentic::ValidationsScope
    

    end

    module Config
    @@ -92,16 +103,16 @@
    end
    end

-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Base
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Email
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::LoggedInStatus
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Login
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::MagicColumns
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Password
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::PerishableToken
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::PersistenceToken
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::RestfulAuthentication
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::SessionMaintenance
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::SingleAccessToken
-::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::ValidationsScope
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Base
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Email
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::LoggedInStatus
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Login
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::MagicColumns
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Password
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::PerishableToken
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::PersistenceToken
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::RestfulAuthentication
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::SessionMaintenance
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::SingleAccessToken
+#::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::ValidationsScope

This then makes it mandatory to do the inclusion at the model level like that, but this is cleaner:

class User < ActiveRecord::Base

include Authlogic::ActsAsAuthentic::Base

Could you consider doing so in a future version please?

I realize that would require every existing project relying on authlogic to add this line but again this improves code separation and stability with ActiveRecord and this improves clarity making it easier to understand the magic involved.

And finally thanks for the authlogic code, sharing and maintaining it!

Since I can't manage to have a clean code formating in the github issue tracker (couldn't find any help) for the patch, here is a link to a nice-formated version: http://pastie.org/695792

Best regards

Collaborator

jaredbeck commented Dec 25, 2016

Closing due to inactivity. If this is something you'd still like to work on, please open a PR, thanks.

@jaredbeck jaredbeck closed this Dec 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment