mercredi 7 novembre 2018

Where is the scope variable declared in this source code?

I've been looking through the source code for devise, for the life of me can't figure out how the below code block works (full source here)

def mapping
    @mapping ||= begin
        mapping = Devise.mappings[scope]
        raise "Could not find mapping for #{scope}" unless mapping
        mapping
    end
end

I think understand most parts of this code, but cannot find where the scope variable is declared/defined. I have searched to repository (and the repository this inherits from), and looked at the tests available to try and get a better idea of what's going on here, but can not find any mention of a scope variable anywhere. I'm still learning ruby, so am I missing something obvious/a language construct that I'm unaware of at work here?

Aucun commentaire:

Enregistrer un commentaire