When the Rails server is started, inside the devise gem code lib/devise/modules.rb calls add_module for all the available modules. lib/devise.rb calls Devise::Mapping.add_module module_name. lib/devise/mapping.rb then builds the methods like registerable? using this code:
# Create magic predicates for verifying what module is activated by this map.
# Example:
#
# def confirmable?
# self.modules.include?(:confirmable)
# end
#
def self.add_module(m)
class_eval <<-METHOD, __FILE__, __LINE__ + 1
def #{m}?
self.modules.include?(:#{m})
end
METHOD
end
If you run the Rails console and then look at one of your devise resources such as :user, you can see the methods that were built by checking out Devise.mappings[:user].methods.sort and you can see the modules that you decided to include in your user model with Devise.mappings[:user].modules.
The "-" in the <% %> code has to do with omitting white space, though it may not be necessary anymore or might vary by browser because there isn't always a noticeable difference (See: Rails ERB <%- ... -%> vs. <% ... %> and Difference between -%> and %> in rails).