0.0
No commit activity in last 3 years
No release in over 3 years
Allows you to follow DCI principles in Ruby on Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.7
 Project Readme

Conderaction

Circle CI Code Climate

A simple implementation of DCI that specifically targets Ruby on Rails.

Do it for the life of the object or only for the life of a block of code.

Conderaction is inspired by Jim Gay's casting gem but provides a Rails-specific twist to DCI.

Here's a quick example that you might try in a Rails project:

# implement a module that contains information for the request response
# and apply it to an object in your system.
def show
  respond_with user.as(UserRepresenter)
end

To use proper delegation, your approach should preserve self as a reference to the original object receiving a method. When the object receiving the forwarded message has its own and separate notion of self, you're working with a wrapper (also called consultation) and not using delegation.

The Ruby standard library includes a library called "delegate", but it is a consultation approach. With that "delegate", all messages are forwarded to another object, but the attendant object maintains its own identity.

With Conderaction, your defined methods may reference self and during execution it will refer to the original client object.

Installation

If you are using Bundler, add this line to your application's Gemfile:

gem 'conderaction'

Or install it yourself as:

$ gem install conderaction

Contributing

  1. Fork it
  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 new Pull Request

Built by SpruceMail