Sha256: cff965562f68eacd54869ca4f3fdb196c16e7b0d23bb4578ca0723d415111546

Contents?: true

Size: 784 Bytes

Versions: 51

Compression:

Stored size: 784 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 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     => 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

51 entries across 51 versions & 1 rubygems

Version Path
picky-4.0.0pre1 lib/picky/adapters/rack.rb
picky-3.6.16 lib/picky/adapters/rack.rb
picky-3.6.15 lib/picky/adapters/rack.rb
picky-3.6.14 lib/picky/adapters/rack.rb
picky-3.6.13 lib/picky/adapters/rack.rb
picky-3.6.12 lib/picky/adapters/rack.rb
picky-3.6.11 lib/picky/adapters/rack.rb
picky-3.6.10 lib/picky/adapters/rack.rb
picky-3.6.9 lib/picky/adapters/rack.rb
picky-3.6.8 lib/picky/adapters/rack.rb
picky-3.6.7 lib/picky/adapters/rack.rb
picky-3.6.6 lib/picky/adapters/rack.rb
picky-3.6.4 lib/picky/adapters/rack.rb
picky-3.6.3 lib/picky/adapters/rack.rb
picky-3.6.2 lib/picky/adapters/rack.rb
picky-3.6.1 lib/picky/adapters/rack.rb
picky-3.6.0 lib/picky/adapters/rack.rb
picky-3.5.4 lib/picky/adapters/rack.rb
picky-3.5.3 lib/picky/adapters/rack.rb
picky-3.5.2 lib/picky/adapters/rack.rb