Friday, November 16, 2012

In Ruby, private methods are visible in derived classes


    class Base
    private
      def hello
      end
    end
then methods in the derived class can call it:

    class Derived < Base
      def say
        hello # this is allowed in Ruby
      end
    end 
 
Simply to say this :
in C++ and OOP languages, “private” means “private to this class”, 
while in Ruby it means “private to that instance”. Again here class is itself an object :-)

Thats means private method will have only one receiver that is self.

Thursday, October 18, 2012

Features of Ruby on Rails 4.0

Features of Rails 4.0:
    •    strong_parameters
    •    Rails.queue
    •    Turbolinks
    •    Russian Doll Caching (cache_digests)
    •    ActionController::Live (streaming)
    •    PATCH verb
    •    Routing concerns
    •    Extraction of activeresource
    •    ActiveRecord::Relation changes and improvements
    •    Removal of plugin support (not gems; only those that are installed in vendor/plugins)
    •    Removal of Rails 2 finder syntax
    •    Deprecation of most dynamic finders
    •    Deprecation of eager-evaluated scopes

Slide deck: speakerdeck.com/u/alindeman/p/rails-4-dot-0-whirlwind-tour

Video:  http://vimeo.com/51181496

Sunday, July 15, 2012

tooltipclass.js for drop down options when mouse over

code : https://github.com/reddyonrails/tooltipclass.js 
 
Description:
 This code is to tooltip drop down option when mouse over. TooltipClass uses json data source .
If this datasource is empty will fetch from ajax url passed from source list url.

You can set a template for each tooltip for drop down box.

sample source params to select particular select box.

Usage:
var dataSourceList = {
    'portfolio': {
        'targetElement': '#analysisjob_portfolio_id',
        'url': '/portfolios',
        'sourceName': 'portfolio',
        'primaryKey': 'portfolio.PortfolioId',
        'jasonData': {},
        'template': "" +
            "<%= item.Name%>" + "
" +
            "<%= item.Description%>" + "
" +
            ""
     }
}
targetElement : select box id
url: ajax url to fetch data
sourceName: json root
primaryKey: key with which we search for json data for each option
template: you can define tooltip structure

loadSource and call tooltipify function like this :
       var source = dataSourceList.portfolio
       var test = TooltipClass.initialize(source);
        test.toolTipfy();

Requirements:
http://twitter.github.com/bootstrap/javascript.html (tooltip,popover)
jquery
underscore.js

Tested in firefox