I use postgres schemes in my Rails application, so there is no clear way to query all companies (for our own analytics). I would like to implement every method that iterates through all companies and switches the postgres schema accordingly.
I would like to call:
Company.each do |company|
but I would also like to get some of the other Enumerable methods, such as collect , in this example, getting all the managers in all companies:
Company.collect do |company| Users.managers end
Currently it works fine for me
class Company < ActiveRecord::Base
but how do I get an enumerated mixin at the class level, and not at the instance level.
ie, when include Enumerable is in a class, Enumerable methods are called as
company = Company.new
but i want to call
and use
Company.each
It seems to me that the answer is obvious, but my metaprogramming foo is weak today.
ruby ruby-on-rails
ideasasylum
source share