Too small for function, too big to be un-DRY

Category: Other - Tools & Utilities

I wanted to execute the same block of code twice in the same procedure, but the block itself I did not feel warranted its own function (this was in a Rails test). So here's a neat trick to keep it DRY. Date: 04 January, 2012


Ruby Function - Un-DRY Ruby - Ruby Snippets - Ruby - Function - Un-DRY

Homepage: http://snippets.dzone.com

Developer: snippets.dzone.com

License: Freeware

Operating System: Windows, Linux

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

This is a Ruby implementation of the native serialize() and unserialize() functions.

developer Developer: download.pureftpd.org
license License: Freeware
operating systems Operating System: All


Split an array of elements into a set of smaller arrays of equal size.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


Split a string into an array of roughly equal sized chunks based on a string or regular expression delimiter.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


Get the currently running method name in Ruby - how to get the running methos name in ruby.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


Float Hacks:to_s override.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


A replacement for Ruby's File.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


The following code will create a live search in your Ruby on Rails project using AJAX.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: All


I needed to grab a days records from MySQL, generate an Excel spreadsheet and then email it as an attachment.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: Windows, Linux


I frequently have a collection of values that I want to match in an ActiveRecord query, but it would be nice if I could let ActiveRecord handle checking the data and escaping it properly.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: Windows, Linux