Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

schema_plus does not play nicely with Tire #109

Open
djcp opened this issue Jun 17, 2013 · 3 comments
Open

schema_plus does not play nicely with Tire #109

djcp opened this issue Jun 17, 2013 · 3 comments

Comments

@djcp
Copy link

djcp commented Jun 17, 2013

Tire ( http://github.com/karmi/tire ) exports ".indexes" on models it's mixed into, as does schema_plus. I'm not sure of a fix here - ideas? Tire makes its methods available under the ".tire" method proxy, so you can call "Model.tire.indexes" as well.

@ronen
Copy link
Member

ronen commented Jun 25, 2013

Can't say that I have any simple immediately bright ideas. Externally, you could define your own methods to call one or the other using something along the lines of

def ActiveRecord::Base.schema_plus_indexes
   SchemaPlus::ActiveRecord::Base.method(:indexes).bind(self).()
end

and likewise for Tire. but that wouldn't help with either gem's use of its own indexes method internally.

Only solution I can think of would be to change schema_plus to define and use a method schema_plus_indexes everywhere internally and provide indexes as an alias to schema_plus_indexes, and do likewise in Tire. That way the internals wouldn't collide, and users of just one of the two could call .indexes as normal, but users of both would need to call schema_plus_indexes or tire_indexes, and/or could re-alias indexes to whichever one they use more often.

(Ruby 2.0's "refinements" would perhaps help with isolating such things for the internal uses, but doesn't address exporting AFAIK)

@sheerun
Copy link

sheerun commented Aug 13, 2013

Imho it should be user.schema_plus.indexes with no alias

@edit Or rather no new methods on models at all, just SchemaPlus.for(User) or something like this

@leotioni
Copy link

In your Tire model you can just use self.tire.indexes
For instance:

mapping do
  self.tire.indexes :id, :index => :not_analyzed
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants