Archive for October, 2010

Method Visibility: Public, Protected, Private


2010
10.25

Instance methods may be publicprivate, or protected.

Methods are normally public unless they are explicitly declared to be private or protected. One exception is the initialize method, which is always implicitly private. Another exception is any “global” method declared outside of a class definition—those methods are defined as private instance methods of Object. A public method can be invoked from anywhere—there are no restrictions on its use.

A private method is internal to the implementation of a class, and it can only be called by other instance methods of the class (or, as we’ll see later, its subclasses). Private methods are implicitly invoked on self, and may not be explicitly invoked on an object. If m is a private method, then you must invoke it in functional style as m. You cannot write o.m or even self.m.

A protected method is like a private method in that it can only be invoked from within the implementation of a class or its subclasses. It differs from a private method in that it may be explicitly invoked on any instance of the class, and it is not restricted to implicit invocation on self. A protected method can be used, for example, to define an accessor that allows instances of a class to share internal state with each other, but does not allow users of the class to access that state.

Using git revert


2010
10.05

Hi,

We are doing revert our code in different different ways.

The basic way of doing this using git revert command.

The git revert commit command is substantially similar to the command git cherry-pic commit with one important difference: it applies the inverse of the given commit. Thus, this command is used to introduce a new commit that reverses the effects of a given commit.

My Current master status

A => B => C => D => E

If we are reverting commit D

Then it will become

A => B => C => D => E => D”

Here D” is the commit reverse of D


Arun

Rake Migration


2010
10.01

Hi,

I have started working on a plugin which helps rails projects to maintain the list of rake tasks.

Here what i am doing is we are maintaining files using version numbers.

As one rake command will tell us what is left to be run in a team environment.

Suppose i have written a rake task or some ruby code to be execute on the db in a order.

Other team member also want’s to run that task on their DB and as well as on production environments.

What this plugin is doing is, when you want to add some ruby code or want’s to run some ruby code in a sequence.

Just create an empty ruby file using rake migration generator and add ruby stuff there.

if you have migrate that file into the DB. Which means that you have applied that ruby code into your environments. Other developer can take your changes and just migrate those things in their DB also.

Idea is same like as DB Migrations are working.

Here is the URL for plugin

http://github.com/arunagw/rake_migration

This plugin is under development currently.

Cheers,

Arun Agrawal