lib/sinclair/method_definition/parameter_helper.rb in sinclair-1.14.0 vs lib/sinclair/method_definition/parameter_helper.rb in sinclair-1.14.1
- old
+ new
@@ -24,11 +24,11 @@
private_class_method :new
# @param parameters_list [Array<Object>] list of parameters and defaults
# @param named [TrueClass,FalseClass] Flag informing if the parameters are
# named parameters
- def initialize(parameters_list, named: false)
+ def initialize(parameters_list, named: nil)
@parameters_list = parameters_list
@named = named
end
# All parameters converted into strings
@@ -38,11 +38,11 @@
#
# @return [Array<String>]
def strings
return [] unless parameters_list
- parameters_strings + defaults_strings
+ parameters_strings + defaults_strings + wild_card_parameters
end
private
delegate :value_string, to: Stringifier
@@ -79,10 +79,21 @@
# of type +Hash+
#
# @return [Array<Symbol>]
def parameters
parameters_list.reject do |param|
- param.is_a?(Hash)
+ param.is_a?(Hash) || param.to_s.match?(/^\*/)
+ end
+ end
+
+ # Returns the named parameters that have not been defined
+ #
+ # THis is usually extra options
+ #
+ # @return [Array<String>]
+ def wild_card_parameters
+ parameters_list.reject do |param|
+ param.is_a?(Hash) || !param.to_s.match?(/^\*/)
end
end
# Hash representing all parameters with default values
#