class Dry::AutoInject::MethodParameters
@api private
Constants
- EMPTY
- PASS_THROUGH
Attributes
parameters[R]
Public Class Methods
new(parameters)
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 53 def initialize(parameters) @parameters = parameters end
of(obj, name)
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 12 def self.of(obj, name) Enumerator.new do |y| begin method = obj.instance_method(name) rescue NameError end loop do break if method.nil? y << MethodParameters.new(method.parameters) method = method.super_method end end end
Public Instance Methods
empty?()
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 81 def empty? parameters.empty? end
keyword?(name)
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 77 def keyword?(name) keyword_names.include?(name) end
keyword_names()
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 71 def keyword_names @keyword_names ||= parameters.each_with_object(Set.new) { |(type, name), names| names << name if type == :key || type == :keyreq } end
length()
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 85 def length parameters.length end
pass_through?()
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 89 def pass_through? PASS_THROUGH.include?(parameters) end
sequential_arguments?()
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 63 def sequential_arguments? return @sequential_arguments if defined? @sequential_arguments @sequential_arguments = parameters.any? { |type, _| type == :req || type == :opt } end
splat?()
click to toggle source
# File lib/dry/auto_inject/method_parameters.rb, line 57 def splat? return @splat if defined? @splat @splat = parameters.any? { |type, _| type == :rest } end