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
end However 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
#where
method will give you a bit of a taste of just how convoluted this gets. :)#where
method is defined on theMongoid::Criteria
class: here#where
method is included in the set of methods thatMongoid::Criteria::Queryable::Selectable
declares as "forwardable", hereMongoid::Document
includesMongoid::Composable
(here), which extendsMongoid::Findable
(here).Mongoid::Findable
delegates those forwardable defined inMongoid::Criteria::Queryable::…