Class: BindableBlock::ArgAligner

Inherits:
Object
  • Object
show all
Defined in:
lib/bindable_block.rb

Overview

match args to arity, since instance_method has lambda properties

Instance Method Summary collapse

Constructor Details

#initialize(args, instance_method) ⇒ ArgAligner

Returns a new instance of ArgAligner.



7
8
9
10
11
12
# File 'lib/bindable_block.rb', line 7

def initialize(args, instance_method)
  @result, @args, @parameters = [], args, instance_method.parameters.map(&:first)
  take num :req
  take [num(:opt), args.size].min
  take args.size if has? :rest
end

Instance Method Details

#callObject



14
15
16
# File 'lib/bindable_block.rb', line 14

def call
  result
end