[READ-ONLY] Mirror of https://github.com/Schniz/delegator.cr. Decorates an object and delegates missing methods to it
0

Configure Feed

Select the types of activity you want to include in your feed.

Crystal 100.0%
6 1 1

Clone this repository

https://tangled.org/schlez.in/delegator.cr https://tangled.org/did:plc:zarxh3r23vwi3jieh3cfn7lr
git@tangled.org:schlez.in/delegator.cr git@tangled.org:did:plc:zarxh3r23vwi3jieh3cfn7lr

For self-hosted knots, clone URLs may differ based on your setup.



README.md

Delegator build status#

Decorates an object and delegates missing methods to it. Based on the code in this gist by @decors

Installation#

Add this to your application's shard.yml:

dependencies:
  delegator:
    github: Schniz/delegator.cr

Usage#

require "delegator"

# Given a class
class Person
  property name
  def initialize(@name); end
end

# Create a subclass of Delegator
class PersonDelegator < Delegator(Person)
  def greet
    "Hello, #{name}!"
  end
end

# Use it to decorate objects!

joe = Person.new("Joe")
PersonDelegator.delegate(joe).greet # "Hello Joe!"

Contributing#

  1. Fork it ( https://github.com/Schniz/delegator.cr/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

Contributors#

  • Schniz Gal Schlezinger - creator, maintainer