Sha256: ad64d3b29197ad5455e1205f55128515b9673977d2bf3a51f6c13e5200f51ae0

Contents?: true

Size: 608 Bytes

Versions: 21

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

module Telnyx
  module APIOperations
    # Intercepts request params passed to api operation methods and wraps them in a single param.
    # Usage:
    # class << self
    #   prepend Telnyx::ParamWrapper
    #   wrap :list, 'filter'
    # end
    module ParamWrapper
      protected

      def wrap(method_name, wrapper)
        define_singleton_method(method_name) do |filters = {}, opts = {}|
          return super(filters, opts) if filters.keys == [wrapper]

          filters = { wrapper => filters }
          super filters, opts
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
telnyx-3.0.5 lib/telnyx/api_operations/param_wrapper.rb
telnyx-3.0.4 lib/telnyx/api_operations/param_wrapper.rb
telnyx-3.0.3 lib/telnyx/api_operations/param_wrapper.rb
telnyx-3.0.2 lib/telnyx/api_operations/param_wrapper.rb
telnyx-3.0.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.9.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.8.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.7.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.6.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.5.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.4.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.3.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-2.2.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-0.1.0 lib/telnyx/api_operations/param_wrapper.rb
telnyx-0.0.8 lib/telnyx/api_operations/param_wrapper.rb
telnyx-0.0.7 lib/telnyx/api_operations/param_wrapper.rb
telnyx-0.0.6 lib/telnyx/api_operations/param_wrapper.rb
telnyx-0.0.5 lib/telnyx/api_operations/param_wrapper.rb
telnyx-0.0.4 lib/telnyx/api_operations/param_wrapper.rb
telnyx-0.0.3 lib/telnyx/api_operations/param_wrapper.rb