Class: TypeWrapper::Forwarding
- Defined in:
- lib/type_wrapper/forwarding.rb
Constant Summary collapse
- DefineMethods =
-> forward, target, base do code = forward.uniq.map do |forwarding| " def \#{forwarding}(*args, &block)\n \#{target}.\#{forwarding}(*args, &block)\n end\n EOS\n end\n base.module_eval code.unshift(\"using Refinements\").join(\"\\n\")\nend\n"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(refinements, *forward, to:) ⇒ Forwarding
constructor
A new instance of Forwarding.
- #inspect ⇒ Object
Methods inherited from Module
Constructor Details
#initialize(refinements, *forward, to:) ⇒ Forwarding
Returns a new instance of Forwarding.
3 4 5 6 7 8 9 10 |
# File 'lib/type_wrapper/forwarding.rb', line 3 def initialize(refinements, *forward, to:) raise ArgumentError, "No List of Methods specified.", caller if forward.empty? raise ArgumentError, "Can't convert #{to}:#{to.class} to Symbol", caller unless to.respond_to? :to_sym const_set :Refinements, refinements DefineMethods[forward, to.to_sym, self] @forward = forward @target = to end |
Class Method Details
.[](*args) ⇒ Object
17 18 19 |
# File 'lib/type_wrapper/forwarding.rb', line 17 def self.[](*args) new *args end |
Instance Method Details
#inspect ⇒ Object
12 13 14 15 |
# File 'lib/type_wrapper/forwarding.rb', line 12 def inspect refinements = const_get :Refinements name || "Forwarding[#{refinements} #{@forward.join(' ')} to: #{@target}]" end |