Storage of variables without initializing an objet? Ruby Gem 'Mail'

Working with the Ruby Gem 'Mail', I am confused as to how variables are able to be stored without initializing an object? For example:

Mail.defaults do
  retriever_method :pop3, :address    => "",
                          :port       => 995,
                          :user_name  => '<username>',
                          :password   => '<password>',
                          :enable_ssl => true

After which you are able to call methods such as Mail.first and have it return the first message in the mailbox with the configured defaults.

I realize everything in Ruby is an object, even a class, so when require 'mail' is called, does an object containing the the class Mail actually get created and mad available to the program? What exactly is happening here?


The contents of mail.rb are loaded into the file that has the require 'mail' statement.

After having a look in the gem, mail.rb contains the Mail module, which in turn contains many other require statements.


module Mail
  ## skipped for brevity

  # Finally... require all the Mail.methods
  require 'mail/mail'


module Mail
  ## skipped for brevity

  # Receive the first email(s) from the default retriever
  # See Mail::Retriever for a complete documentation.
  def self.first(*args, &block)
    retriever_method.first(*args, &block)

So then the methods are made available to your program.

Need Your Help

How to apply digital signature to Visual Studio projects?

visual-studio binary certificate signing

Executables and DLL's can be digitally signed. It suggests trust to the user.

DuplicateKeyException even after removing unique constraints

java db2 constraints unique

I'm working on db2. I got one table, which contains some data:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.