Ruby through rails part 4: Bundler Dsl

Where is ‘new’ defined in Ruby? What does instance_eval do? How is a Gemfile parsed? Did you know that “gem”, “source” and “ruby” are method defined in the Bundler gem? Read and learn about more constructs and the Bundler DSL for parsing the Gemfile.


Bundler::Dsl class is defined inside the lib/bundler/dsl.rb. Earlier we have learned how various settings get set like the bundle path and gem path. Now we are going to learn how the Gemfile is parsed and evaluated. Bundler::Dsl.evaluate gets called from Bundler::Definition#build function.

‘evaluate’ method is singleton method on class Dsl and the parameters passed to it are Gemfile path, Gemfile.lock path and a boolean field from Bundler::Definition#build function. In above function, it calls the ‘new’ function. There is nothing new about the ‘new’ function. It basically creates the object for a class. Howevr, have you ever given thought where ‘new’ function defined?

What is the ‘new’ function in Ruby?

‘new’ is instance method of class Class. Classes in Ruby are first-class objects—each is an instance of class Class.When a new class is defined (typically using class SomeName … end), an object of type Class is created and assigned to a constant (SomeName, in this case)…

View original post 460 more words

About Gautam Rege

Rubyist, Entrepreneur and co-founder of Josh-Software - one of the leading Ruby development shops in India.
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s