How does a Model have access to a class method like where?
#5858
-
|
As per the docs, one should add class Band
include Mongoid::Document
endHowever my question is, according to this and other stack overflow posts, Obviously it is being inherited I'm just trying to understand how, and where I went wrong with my logic :) Thanks Context: My LSP can't pick up the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Mongoid makes very heavy use of delegation and metaprogramming. It also uses Looking specifically at the
So, putting that all together, we can see that |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for such a detailed answer! |
Beta Was this translation helpful? Give feedback.
Mongoid makes very heavy use of delegation and metaprogramming. It also uses
ActiveSupport::Concern(from Rails) so that you can define class methods in a module that get applied when the module is included.Looking specifically at the
#wheremethod will give you a bit of a taste of just how convoluted this gets. :)#wheremethod is defined on theMongoid::Criteriaclass: here#wheremethod is included in the set of methods thatMongoid::Criteria::Queryable::Selectabledeclares as "forwardable", hereMongoid::DocumentincludesMongoid::Composable(here), which extendsMongoid::Findable(here).Mongoid::Findabledelegates those forwardable defined inMongoid::Criteria::Queryable::…