Skip to content

Instantly share code, notes, and snippets.

View apux's full-sized avatar

Azarel Doroteo Pacheco apux

View GitHub Profile
@ryanb
ryanb / issues_with_modules.md
Created November 29, 2012 22:38
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article < ActiveRecord::Base
@sumskyi
sumskyi / .pryrc.rb
Created July 22, 2011 06:22
my .pryrc
Pry.config.editor = "gvim --remote-silent"
Pry.hooks.add_hook(:after_session, :say_bye) do
puts "fuck off Gnida"
end
Pry.prompt = [Proc.new{ |obj, nest_level| "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL} (#{obj}):#{nest_level} > " },
Proc.new{ |obj, nest_level| "#{RUBY_VERSION} (#{obj}):#{nest_level} * " } ]