Sha256: bf87380ccd86e9fb0bdf2185f5d23fcdf2b1424057c538c7b7b378096d73f954

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
gutentag-0.9.0 lib/gutentag/tagged_with.rb