Sha256: 8803815842103d58eff0fd0ea9e4a621684283af561a0b3337ba982ff0423d25

Contents?: true

Size: 431 Bytes

Versions: 1

Compression:

Stored size: 431 Bytes

Contents

module Aquarium
  module Utils
    module MethodUtils
      def self.method_args_to_hash *args
        return {} if args.empty? || (args.size == 1 && args[0].nil?)
        hash = (args[-1] and args[-1].kind_of? Hash) ? args.pop : {}
        args.each do |arg|
          if block_given?
            hash[arg] = yield arg
          else 
            hash[arg] = nil
          end
        end
        hash
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aquarium-0.1.0 lib/aquarium/utils/method_utils.rb