0.0
No commit activity in last 3 years
No release in over 3 years
This is a library to extend Forwardable functions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0
 Project Readme

ForwardableX

ForwardableX is a Ruby library to extend forwardable.rb.

Gem Version Build Status Coverage Status Code Climate

Installation

gem install forwardablex

Usage

Forward to Instance Variable

Receiver = Struct(:m)
class Forwarder
  forward :@receiver, :m
  def initialize
    @recevier = Receiver.new("forwarded")
  end
end
Forwarder.new.m #=> "forwarded"

Forward to Proc Receiver

class Forwarder
  forward lambda{Struct(:m).new("forwarded")}, :m
end
Forwarder.new.m #=> "forwarded"

Forward to Instance

Receiver = Struct(:m)
class Forwarder
  forward Receiver.new("forwarded"), :m
end
Forwarder.new.m #=> "forwarded"

Class Method Accessor

class Forwarder
  class << self
    def m
      "forwarded"
    end
  end
  forward :class, :m
end
Forwarder.new.m #=> "forwarded"

Table Accessor

class Forwarder
  forward_as_key :@table, :key

  def initialize
    @table = {:key => "forwarded"}
  end
end
Forwarder.new.key #=> "forwarded"

Identity

class Forwarder
  foward :identity, :self
end
Forwarder.new {|x| x == x.self} #=> true

Documentation

Licence

ForwardableX is free software distributed under MIT licence.

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