extend and include in ruby

I have been trying to clean up some old code with Ruby modules. This post is to help me remember the differences between include and extend in Ruby.

class Foo
  extend ActionView::Helpers::NumberHelper
end
module Foo
  extend ActionView::Helpers::NumberHelper
end
Foo.number_to_currency 2
 => "$2.00"
class Foo
  include ActionView::Helpers::NumberHelper
end
foo = Foo.new
foo.number_to_currency 2
 => "$2.00"
comments powered by Disqus