Sha256: 6fd2bab30eb6e0ffa4cf31c17ddf00c33e33940d982c64bbbad0c37245d3e700

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 Bytes

Contents

require 'cgi'
require 'active_model'

module Conquiro
  class Criteria < Struct.new(:term, :country, :media, :entity, :attribute, :limit, :version, :explicit)
    include ActiveModel::Validations
    DEFAULT_COUNTRY = 'us'

    validates :term, presence: true
    validates :country, presence: true

    def country
      super || DEFAULT_COUNTRY
    end

    def params
      self.to_h.select { |_,value| value.present? }
    end

    def term
      CGI.escape(super || '')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conquiro-0.0.3 lib/conquiro/criteria.rb
conquiro-0.0.2 lib/conquiro/criteria.rb
conquiro-0.0.1 lib/conquiro/criteria.rb