Sha256: 04f660cb8afb0b71535fd08c99d4ec4d4cf392eb8c6a2f134a48665a06bca494

Contents?: true

Size: 830 Bytes

Versions: 11

Compression:

Stored size: 830 Bytes

Contents

class Whoops::Filter
  include Mongoid::Document
  include FieldNames
  
  [:service, :environment, :event_type, :message, :details].each do |document_field|
    field document_field, :type => Array
  end
    
  def to_query_document
    doc = attributes.except(:_id, "_id").delete_if{|k, v| v.blank?}
    # match all services under namespace. ie, if "app" given, match "app.web", "app.backend" etc
    doc["service"] = doc["service"].collect{ |d| /^#{d}/ } if doc["service"]
    doc.inject({}) do |hash, current|
      hash[current.first.to_sym.in] = current.last unless current.last.empty?
      hash
    end
  end

  class << self
    def new_from_params(params)
      if params
        new(params.inject({}){|hash, current| hash[current.first] = current.last.keys; hash})
      else
        new
      end
    end
  end   
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
whoops-0.3.5 app/models/whoops/filter.rb
whoops-0.3.4 app/models/whoops/filter.rb
whoops-0.3.3 app/models/whoops/filter.rb
whoops-0.3.2 app/models/whoops/filter.rb
whoops-0.3.1 app/models/whoops/filter.rb
whoops-0.3 app/models/whoops/filter.rb
whoops-0.2.4 app/models/whoops/filter.rb
whoops-0.2.3 app/models/whoops/filter.rb
whoops-0.2.2 app/models/whoops/filter.rb
whoops-0.2.1 app/models/whoops/filter.rb
whoops-0.2 app/models/whoops/filter.rb