Sha256: 58bb941c6faea4b208c96c78618d37dd73e4faedd15f00851e1bc84d025e98c4
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
module ActsAsTaggableOn::Taggable::TaggedWithQuery class QueryBase def initialize(taggable_model, tag_model, tagging_model, tag_list, options) @taggable_model = taggable_model @tag_model = tag_model @tagging_model = tagging_model @tag_list = tag_list @options = options end private attr_reader :taggable_model, :tag_model, :tagging_model, :tag_list, :options def taggable_arel_table @taggable_arel_table ||= taggable_model.arel_table end def tag_arel_table @tag_arel_table ||= tag_model.arel_table end def tagging_arel_table @tagging_arel_table ||=tagging_model.arel_table end def tag_match_type(tag) matches_attribute = tag_arel_table[:name] matches_attribute = matches_attribute.lower unless ActsAsTaggableOn.strict_case_match if options[:wild].present? tag_arel_table[:name].matches("%#{escaped_tag(tag)}%", "!") else tag_arel_table[:name].matches(escaped_tag(tag), "!") end end def tags_match_type matches_attribute = tag_arel_table[:name] matches_attribute = matches_attribute.lower unless ActsAsTaggableOn.strict_case_match if options[:wild].present? matches_attribute.matches_any(tag_list.map{|tag| "%#{escaped_tag(tag)}%"}, "!") else matches_attribute.matches_any(tag_list.map{|tag| "#{escaped_tag(tag)}"}, "!") end end def escaped_tag(tag) tag = tag.downcase unless ActsAsTaggableOn.strict_case_match tag.gsub(/[!%_]/) { |x| '!' + x } end def adjust_taggings_alias(taggings_alias) if taggings_alias.size > 75 taggings_alias = 'taggings_alias_' + Digest::SHA1.hexdigest(taggings_alias) end taggings_alias end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts-as-taggable-on-5.0.0 | lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb |