Class: Dry::AutoInject::MethodParameters Private
- Inherits:
-
Object
- Object
- Dry::AutoInject::MethodParameters
- Defined in:
- lib/dry/auto_inject/method_parameters.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- PASS_THROUGH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[[:rest]]
- EMPTY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
new([])
Instance Attribute Summary collapse
- #parameters ⇒ Object readonly private
Class Method Summary collapse
- .of(obj, name) ⇒ Object private
Instance Method Summary collapse
- #empty? ⇒ Boolean private
-
#initialize(parameters) ⇒ MethodParameters
constructor
private
A new instance of MethodParameters.
- #keyword?(name) ⇒ Boolean private
- #keyword_names ⇒ Object private
- #length ⇒ Object private
- #pass_through? ⇒ Boolean private
- #sequential_arguments? ⇒ Boolean private
- #splat? ⇒ Boolean private
Constructor Details
#initialize(parameters) ⇒ MethodParameters
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MethodParameters.
51 52 53 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 51 def initialize(parameters) @parameters = parameters end |
Instance Attribute Details
#parameters ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 49 def parameters @parameters end |
Class Method Details
.of(obj, name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 27 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 |
Instance Method Details
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 77 def empty? parameters.empty? end |
#keyword?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 73 def keyword?(name) keyword_names.include?(name) end |
#keyword_names ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 70 71 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 67 def keyword_names @keyword_names ||= parameters.each_with_object(Set.new) { |(type, name), names| names << name if type == :key || type == :keyreq } end |
#length ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 81 def length parameters.length end |
#pass_through? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 85 def pass_through? parameters.eql?(PASS_THROUGH) end |
#sequential_arguments? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 65 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 60 def sequential_arguments? return @sequential_arguments if defined? @sequential_arguments @sequential_arguments = parameters.any? { |type, _| type == :req || type == :opt } end |
#splat? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 58 |
# File 'lib/dry/auto_inject/method_parameters.rb', line 55 def splat? return @splat if defined? @splat @splat = parameters.any? { |type, _| type == :rest } end |