Sha256: f3500b5d6468d7b61bc86ee67d7c8403bcedc8a4504c3b928f2849fd1853c9b2

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

module Picky

  module Adapters

    # This is an adapter that is plugged into a Rack outlet.
    #
    # It looks at what is given to it and generate an appropriate
    # adapter for it.
    #
    # For example, if you give it a query, it will extract the query param etc.
    # and call search_with_text on it if it is called by Rack.
    #
    # Usage:
    #   Adapters::Rack.app_for(thing, options)
    #
    module Rack

      # Generates the appropriate app for Rack.
      #
      @@mapping = {
        :search_with_text => Search,
        :parameters       => LiveParameters
      }
      def self.app_for thing, options = {}
        @@mapping.each_pair do |method, adapter|
          return adapter.new(thing).to_app(options) if thing.respond_to?(method)
        end
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-3.0.0.pre1 lib/picky/adapters/rack.rb