[katello-devel] Runcible - replacing classes with instances

Eric Helms ehelms at redhat.com
Fri Oct 12 17:15:03 UTC 2012


On 10/11/2012 05:16 AM, Petr Chalupa wrote:
> 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
While the config is in theory defined globally, you could easily set the 
config before a call to point to another pulp instance.  Which, as I 
understand it, would be the same if we were using an instance based 
approach.  Instead we'd just be passing the config data to the instance 
at creation time and then making the API call for every place there was 
an API call.
> - Resources are defined globally, you cannot stub just something in tests
>
This I don't entirely follow - if you wouldn't mind expounding a bit.
> 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