public
Description: Rails plugin that provides a simple API for extending a model/class from a module.
Homepage: http://henrik.nyh.se/2008/09/augmentations
Clone URL: git://github.com/henrik/augmentations.git
augmentations / init.rb
100644 18 lines (15 sloc) 0.396 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# "Augmentations" plugin for Rails.
# By Henrik Nyh <http://henrik.nyh.se> for DanceJam <http://dancejam.com> 2008-09-10.
# Free to modify and redistribute with credit.
# See README for usage.
 
class ::Object
  def self.augment(*mods)
    include *mods
    mods.each {|mod| class_eval &mod.augmentation }
  end
end
 
class ::Module
  def augmentation(&block)
    @augmentation ||= block
  end
end