Rdecorator is an Pyhton like decorator use for AOP pattern programming
Add this line to your application's Gemfile:
gem 'rdecorator'
And then execute:
$ bundle
class Language
extend Rdecorator
def best(this, args)
'best Language' + this.call(args)
end
wrap :best
def ruby
'ruby'
end
end
Language.new.ruby #=> best Language ruby
class Decorator
include Rdecorator
def call
'say fucking' + @this.call(*@args)
end
end
class DummyClass
decorator Decorator
def say(hello)
'hello'
end
end
Bug reports and pull requests are welcome on GitHub at https://github.com/falm/rdecorator.