This file contains 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 'model_attribute' | |
module ActiveRecordMimic | |
def self.included(base) | |
base.instance_eval do | |
unless (class << base; self; end).ancestors.include?(ModelAttribute) | |
raise "ActiveRecordMimic aliases ModelAttribute methods so must be included after extending ModelAttribute" | |
end | |
alias_method :[], :read_attribute |
This file contains 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 Bottles | |
def song | |
verses(99, 0) | |
end | |
def verses(upper_bound, lower_bound) | |
upper_bound.downto(lower_bound).map { |i| verse(i) }.join("\n") | |
end |