[katello-devel] Runcible - replacing classes with instances

Petr Chalupa pchalupa at redhat.com
Thu Oct 11 09:16:03 UTC 2012


Hi

I like what you are doing around Pulp v2, Runcible and usage of vcr is 
great.

I would have one suggestion though to replace class-implementation of 
runcible with instances. I would suggest to move all the 
functionality/methods from class (Runcible::Base, 
Runcible::Resources::*) to instances to avoid some limitations:

- gem cannot be used to connect to more then one Pulp instance, config 
is defined globally
- Resources are defined globally, you cannot stub just something in tests

Also imho it is good practice not to create singletons unless it is 
really needed. Singletons can be defined in Katello later (like we did 
in foreman_architectures, see [1]) without compromising the ability to 
use different Resource instance in an object if needed, see [2][3].

Petr

[1] 
https://github.com/Katello/katello/blob/0dd082076ff91761e2a03353c9a340754f902749/src/lib/resources/foreman.rb
[2] 
https://github.com/Katello/katello/blob/0dd082076ff91761e2a03353c9a340754f902749/src/lib/resources/abstract_model.rb#L128
[3] 
https://github.com/Katello/katello/blob/0dd082076ff91761e2a03353c9a340754f902749/src/lib/resources/foreman_model.rb#L15




More information about the katello-devel mailing list