>> %w(Pending Processing Executed Canceled).each_with_index.map {|v, i| i}
=> [0, 1, 2, 3]

Ruby Get array of indexes from g...

by jibiel, December 08, 2011 00:18, 5 refactorings, tagged with rails, dry, ruby-1.9.2

Using it :in validates_incl...

4b3896c9b63e756621efa3746c32e91b Talk
def sort
    if params[:fact_id]
      @fact = Fact.find_by_id(params[:fact_id]) || Fact.new
...

Ruby Ugly IF, ELSE

by serek.openid.pl, December 18, 2009 10:17, 3 refactorings, tagged with rails, short, dry

Trying to make this a lot c...

597821ce12359ab2d95437c8164d5254 Talk
<?php

// open the db connection
...

PHP DRY switch

by htxt, June 10, 2009 10:16, 1 refactoring, tagged with php, dry, switch, wordpress

This is part of an events p...

13e1f55ad0de3139470536022839ed89 Talk
def show
    
    if params[:course_id] && permitted_to?(:browse, :videos)
...

Ruby Need to DRY this if-else up

by fnjord.myopenid.com, March 25, 2009 17:43, 3 refactorings, tagged with rails, ruby, dry, conditions, if else

I thought of creating a bef...

321bbdb120165eebbaf37e781d4ec71b Talk
public class MvNetDB
    {
        protected mvAccount _account = null;
...

C# Help me with ineritance or ...

by mikeroosa.myopenid.com, February 05, 2009 13:27, 3 refactorings, tagged with C#, dry, database

I'm new to C# and working o...

56982d0ab4f8fdd82cf65d399f25b774 Talk
class PeopleController < ApplicationController

...

Ruby Re-use code for new and cre...

by Dave, November 05, 2008 09:30, 4 refactorings, tagged with rails, dry, controller

Hello,

I have a 'people'...

997adc3b63a05bf75f833c48fa246e19 Talk
def planned_percent_complete
    if self.planned_complete_in_dollars != nil
      (( self.planned_complete_in_dollars.to_f / self.task.budget.to_f )  * 100).round(2)
...

Ruby Same methods, different Act...

by Chris W., January 08, 2008 18:31, 6 refactorings, tagged with rails, ruby, activerecord, dry

I know there has to be a "r...

D41d8cd98f00b204e9800998ecf8427e Talk