156 reputation
16
bio website
location Austin, TX
age 29
visits member for 2 years, 11 months
seen Apr 4 at 16:43

Jul
25
comment Do mixins create coupling with Ruby?
So you would recommend I go a dependency injection route to provide classes access to the keyring instance? Isn't this anti-Ruby, considering everyone advocates modules/mixins over DI?
Jul
25
comment Do mixins create coupling with Ruby?
Thanks for the added response. So, let's say I put the keyring instance in the App module. Would I then "include App" in my FtpConnection class and access the keyring instance there via the "keyring" method which would be mixed into the FtpConnection class? Or would I access the keyring instance in FtpConnection via "App.keyring"? Or something else?
Jul
25
awarded  Supporter
Jul
25
comment Do mixins create coupling with Ruby?
My application needs one keyring instance for use with multiple other classes application-wide. This is similar to a database connection. Using a dependency injection-based design, I would instantiate the keyring object at the application level, store it in a registry, and access it as a service via a service locator. Thus, it is not a singleton. Does this make sense? What would you recommend I do, considering it is needed application wide?
Jul
25
comment Do mixins create coupling with Ruby?
Maybe a symbol name could be used for the module name. Or, better yet, maybe a fancy class macro could be used in conjunction with a symbol. Hm. Does anyone know a commonly-used way around this coupling?
Jul
25
comment Do mixins create coupling with Ruby?
Well, I'm comparing this to a dependency injection approach, which might be closer to perfect and would not require copying and pasting.
Jul
25
asked Do mixins create coupling with Ruby?
Jul
25
awarded  Student
Apr
23
asked What is ActiveRecord in Rails?