Module: ActiveCopy::Finders

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_copy/finders.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#matches?(query) ⇒ Boolean

Test if the query matches this particular model.

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
# File 'lib/active_copy/finders.rb', line 9

def matches? query
  query.reduce(true) do |matches, (key, value)|
    matches = if key == 'tag'
      return false unless tags.present?
      tags.include? value
    else
      attributes[key] == value
    end
  end
end