Sha256: 1386ba7d498acb9c6a0fc7a59965c86f5a7b07a8b5c42667d4374375e5fee30f
Contents?: true
Size: 721 Bytes
Versions: 1
Compression:
Stored size: 721 Bytes
Contents
# frozen_string_literal: true require 'active_support/concern' module Metka # Extends AR model with methods to use tags module Model extend ActiveSupport::Concern included do scope :tagged_with, ->(tags, options = {}) do tag_list = Metka.config.parser.instance.call(tags) options = options.dup return none if tag_list.empty? where(::Metka::QueryBuilder.new.call(self, 'tags', tag_list, options)) end end def tag_list=(v) self.tags = Metka.config.parser.instance.call(v).to_a self.tags = nil if tags.empty? end def tag_list Metka.config.parser.instance.call(tags) end module ClassMethods # :nodoc: end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metka-0.1.2 | lib/metka/model.rb |