Sha256: 92f3e4fa66e48bbffc72d3ba2a3455e16592d5b63df6147c290df2fb7102a0c2

Contents?: true

Size: 695 Bytes

Versions: 19

Compression:

Stored size: 695 Bytes

Contents

# frozen_string_literal: true

class Gutentag::TaggedWith
  def self.call(model, options)
    new(model, options).call
  end

  def initialize(model, options)
    @model   = model
    @options = options
  end

  def call
    query_class.new(model, values, match).call
  end

  private

  attr_reader :model, :options

  def match
    options[:match] || :any
  end

  def query_class
    options[:names] ? NameQuery : IDQuery
  end

  def values
    if options[:tags]
      Array(options[:tags]).collect(&:id)
    else
      options[:ids] || options[:names]
    end
  end
end

require "gutentag/tagged_with/query"
require "gutentag/tagged_with/id_query"
require "gutentag/tagged_with/name_query"

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gutentag-2.6.2 lib/gutentag/tagged_with.rb
gutentag-2.6.1 lib/gutentag/tagged_with.rb
gutentag-2.6.0 lib/gutentag/tagged_with.rb
gutentag-2.5.4 lib/gutentag/tagged_with.rb
gutentag-2.5.3 lib/gutentag/tagged_with.rb
gutentag-2.5.2 lib/gutentag/tagged_with.rb
gutentag-2.5.1 lib/gutentag/tagged_with.rb
gutentag-2.5.0 lib/gutentag/tagged_with.rb
gutentag-2.4.1 lib/gutentag/tagged_with.rb
gutentag-2.4.0 lib/gutentag/tagged_with.rb
gutentag-2.3.2 lib/gutentag/tagged_with.rb
gutentag-2.3.1 lib/gutentag/tagged_with.rb
gutentag-2.3.0 lib/gutentag/tagged_with.rb
gutentag-2.2.1 lib/gutentag/tagged_with.rb
gutentag-2.2.0 lib/gutentag/tagged_with.rb
gutentag-2.1.0 lib/gutentag/tagged_with.rb
gutentag-2.0.0 lib/gutentag/tagged_with.rb
gutentag-1.1.0 lib/gutentag/tagged_with.rb
gutentag-1.0.0 lib/gutentag/tagged_with.rb