This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Thing | |
def do_something | |
puts "Doing something in Thing" | |
end | |
end | |
class SubThing < Thing | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Friendly | |
def greet | |
puts "Hello World!" | |
end | |
end | |
class HelloWorld | |
include Friendly | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Base | |
is_paranoid | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_paranoid opts = {} | |
# ...snip... | |
include InstanceMethods | |
end | |
module InstanceMethods | |
# snip snip snip | |
def destroy | |
# ....etc. | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Thing | |
def do_something | |
puts "Doing something in Thing" | |
end | |
end | |
class SubThing < Thing | |
end | |
module IneffectiveOverride |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def start | |
puts "Starting round #{@rounds + 1}" | |
say('start', 5) | |
3.times do |minute| | |
sleep 60 | |
say("Ending minute #{minute + 1}") | |
end | |
@rounds += 1 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
class TestMe < Test::Unit::TestCase | |
end if | |
class Me | |
def a_method | |
end | |
false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pathname' | |
class FileDB | |
class ModuleDefiner | |
class ClassDefiner | |
end | |
end | |
class << self | |
def from_dir(path) | |
with_module_for(module_name_for(path)) do |m| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveSomething | |
class Base | |
def self.setup_methods! | |
columns = File.readlines("#{self.name}.schema").map do |line| | |
line.chomp.split(/:/) | |
end | |
columns.each do |name, column_type| | |
instance_eval{attr_accessor name} | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to find out where a method comes from. | |
# Learned this from Dave Thomas while teaching Advanced Ruby Studio | |
# Makes the case for separating method definitions into | |
# modules, especially when enhancing built-in classes. | |
module Perpetrator | |
def crime | |
end | |
end | |
class Fixnum |