Module: EventSorcerer::ArgumentHashifier
- Defined in:
- lib/event_sorcerer/argument_hashifier.rb
Overview
Public: Helper to hashify a method call.
Class Method Summary collapse
-
.hashify(parameters, arguments) ⇒ Object
Public: Creates a Hash representing a particular method call.
Class Method Details
.hashify(parameters, arguments) ⇒ Object
Public: Creates a Hash representing a particular method call.
parameters - an Array of the parameters for a method. arguments - an Array of the arguments for a particular method call.
Returns a Hash where arguments are keyed by the corrosponding parameter name.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/event_sorcerer/argument_hashifier.rb', line 11 def self.hashify(parameters, arguments) {}.tap do |hash| required_positionals(parameters).each do |param| hash[param] = arguments.shift end keyword_arguments = arguments.last.is_a?(Hash) ? arguments.pop : {} hash.merge! keyword_arguments end end |