falm / rdecorator

yet another ruby decorator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RDecorator

Build Status Coverage Status Dependency Status Code Climate

Rdecorator is an Pyhton like decorator use for AOP pattern programming

Installation

Add this line to your application's Gemfile:

gem 'rdecorator'

And then execute:

$ bundle

Usage

Basic

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

Decorator Class

class Decorator 

  include Rdecorator

  def call
    'say fucking' + @this.call(*@args)
  end
end

class DummyClass

  decorator Decorator
  def say(hello)
    'hello'	
  end

end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/falm/rdecorator.

About

yet another ruby decorator

License:MIT License


Languages

Language:Ruby 97.7%Language:Shell 2.3%