Project

veils

0.0
No release in over a year
Decorate your existing Ruby object with veils and some its methods will be cached.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Ruby Decorator for "Veil" Objects

EO principles respected here DevOps By Rultor.com We recommend RubyMine

rake Gem Version Maintainability Yard Docs Hits-of-Code License

Read this blog post first: Veil Objects to Replace DTOs.

First, install it:

gem install veils

Then, use it like this:

require 'veil'
obj = Veil.new(obj, to_s: 'Hello, world!')

The method to_s will return Hello, world! until some other method is called and the veil is "pierced."

You can also use the Unpiercable decorator, which will never be pierced: a very good instrument for data memoization.

You can also try AlterOut, which lets you modify the output of object methods on the fly:

require 'alterout'
obj = AlterOut.new(obj, to_s: proc { |s| s + 'extra tail' })

There is also the AlterIn decorator, to modify incoming method arguments (the result of the proc will replace the list of input arguments):

require 'alterin'
obj = AlterIn.new(obj, print: proc { |i| [i + 1] })

Keep in mind that all classes are thread-safe.

How to contribute

Read these guidelines. Make sure your build is green before you contribute your pull request. You will need to have Ruby 2.3+ and Bundler installed. Then:

bundle update
bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.