Sha256: 640d857b9ecedf34731441398a647afc16bf91bc49877f1431b6ba79c0708476

Contents?: true

Size: 422 Bytes

Versions: 3

Compression:

Stored size: 422 Bytes

Contents

module Emites

  class Params
    def initialize(attributes = {})
      @attributes = symbolize_keys(attributes)
    end

    def permit(filters)
      filters.map(&:to_sym).each_with_object(Hash.new) do |key, result|
        result[key] = @attributes[key] if @attributes.has_key?(key)
      end
    end

    private

    def symbolize_keys(hash)
      Hash[hash.map { |key,value| [key.to_sym, value] }]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
emites-client-0.1.4 lib/emites/params.rb
emites-client-0.1.3 lib/emites/params.rb
emites-client-0.1.2 lib/emites/params.rb