Sha256: 29b73d6ea9c11dccb24d7825446a5dae613ff20320db7ef9609a34cb6a58e6da

Contents?: true

Size: 369 Bytes

Versions: 7

Compression:

Stored size: 369 Bytes

Contents

require 'rest-core/middleware'

class RestCore::DefaultQuery
  def self.members; [:query]; end
  include RestCore::Middleware

  def initialize *args
    super
    @query ||= {}
  end

  def call env, &k
    defaults = string_keys(@query).merge(string_keys(query(env)))

    app.call(env.merge(REQUEST_QUERY =>
      defaults.merge(env[REQUEST_QUERY])), &k)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rest-core-3.2.0 lib/rest-core/middleware/default_query.rb
rest-core-3.1.1 lib/rest-core/middleware/default_query.rb
rest-core-3.1.0 lib/rest-core/middleware/default_query.rb
rest-core-3.0.0 lib/rest-core/middleware/default_query.rb
rest-core-2.1.2 lib/rest-core/middleware/default_query.rb
rest-core-2.1.1 lib/rest-core/middleware/default_query.rb
rest-core-2.1.0 lib/rest-core/middleware/default_query.rb