Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joker1007/refining

Syntax Sugar of inline refinement module
https://github.com/joker1007/refining

Last synced: 2 days ago
JSON representation

Syntax Sugar of inline refinement module

Awesome Lists containing this project

README

        

# Refining

This gem defines `Class#refining`.

`Class#refining` is helper of defining refinement module at inner class.

### before

```ruby
class User
module AdministratorRoll
refine User do
def delete_post(name)
"Delete: #{name}"
end
end
end
end

class DeletePostContext
using User::AdministratorRoll

def execute
user = User.new
user.delete_post
end
end
```

### after

```ruby
require 'refining'

class User
refining :AdministratorRoll do
def delete_post(name)
"Delete: #{name}"
end
end
end

class DeletePostContext
using User::AdministratorRoll

def execute
user = User.new
user.delete_post
end
end
```

## Installation

Add this line to your application's Gemfile:

gem 'refining'

And then execute:

$ bundle

Or install it yourself as:

$ gem install refining

## Contributing

1. Fork it ( https://github.com/joker1007/refining/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request