lib/quirky-api/response/response_adapter.rb
# Retrieves all adapters, homegrown and custom, that will be used to
# manipulate our response.
Retrieves all adapters, homegrown and custom, that will be used to
manipulate our response.
Retrieves all adapters homegrown and custom that will be used to manipulate our response .
def configured_adapters
        adapters = ADAPTERS.dup
        QuirkyApi.adapters.all.each do |configured_adapter|
          index = adapters.index(configured_adapter[:adapter])
          old_adapter = adapters[index]
          case configured_adapter[:placement]
          when '+1'
            adapters[index, 1] = [old_adapter, configured_adapter[:new_adapter]]
          when '-1'
            adapters[index, 1] = [configured_adapter[:new_adapter], old_adapter]
          end
        end
        adapters
      end
def configured_adapters adapters = ADAPTERS . dup QuirkyApi . adapters . all . each do | configured_adapter | index = adapters . index ( configured_adapter [ :adapter ] ) old_adapter = adapters [ index ] case configured_adapter [ :placement ] when '+1' adapters [ index , 1 ] = [ old_adapter , configured_adapter [ :new_adapter ] ] when '-1' adapters [ index , 1 ] = [ configured_adapter [ :new_adapter ] , old_adapter ] end end adapters end
Retrieves all adapters, homegrown and custom, that will be used to
manipulate our response.
Retrieves all adapters homegrown and custom that will be used to manipulate our response .
# Get our adapters as above. # Get all configured custom adapters and iterate over them. # Get the index of the adapter that will be used to determine # placement on the custom adapter. # Get the pre-existing adapter at that index. # Determine the placement of the new adapter by the 'placement' # specified when you configured it (based upon insert_before/after). # '+1' here means the new adapter should go after the old one, '-1' # means it should go before the old one. # Append # Put the new adapter immediately after the old adapter. # Prepend # Put the ne wadapter immediately before the old adapter. # Return all adapters such as they are.