Module: ActsAsTaggableOn::Taggable::Related
- Defined in:
- lib/acts-as-taggable-on/taggable/related.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #find_matching_contexts(search_context, result_context, options = {}) ⇒ Object
- #find_matching_contexts_for(klass, search_context, result_context, options = {}) ⇒ Object
- #matching_contexts_for(search_context, result_context, klass, _options = {}) ⇒ Object
- #related_tags_for(context, klass, options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 9 |
# File 'lib/acts-as-taggable-on/taggable/related.rb', line 6 def self.included(base) base.extend ActsAsTaggableOn::Taggable::Related::ClassMethods base. end |
Instance Method Details
#find_matching_contexts(search_context, result_context, options = {}) ⇒ Object
33 34 35 |
# File 'lib/acts-as-taggable-on/taggable/related.rb', line 33 def find_matching_contexts(search_context, result_context, = {}) matching_contexts_for(search_context.to_s, result_context.to_s, self.class, ) end |
#find_matching_contexts_for(klass, search_context, result_context, options = {}) ⇒ Object
37 38 39 |
# File 'lib/acts-as-taggable-on/taggable/related.rb', line 37 def find_matching_contexts_for(klass, search_context, result_context, = {}) matching_contexts_for(search_context.to_s, result_context.to_s, klass, ) end |
#matching_contexts_for(search_context, result_context, klass, _options = {}) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/acts-as-taggable-on/taggable/related.rb', line 41 def matching_contexts_for(search_context, result_context, klass, = {}) = (search_context).map(&:name) (klass, [ "#{exclude_self(klass, id)} #{klass.table_name}.#{klass.primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id AND #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = '#{klass.base_class}' AND #{ActsAsTaggableOn::Tagging.table_name}.tag_id = #{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key} AND #{ActsAsTaggableOn::Tag.table_name}.name IN (?) AND #{ActsAsTaggableOn::Tagging.table_name}.context = ?", , result_context ]) end |
#related_tags_for(context, klass, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/acts-as-taggable-on/taggable/related.rb', line 50 def (context, klass, = {}) = Array.wrap([:ignore]).map(&:to_s) || [] = (context).map(&:name).reject { |t| .include? t } (klass, [ "#{exclude_self(klass, id)} #{klass.table_name}.#{klass.primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id AND #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = '#{klass.base_class}' AND #{ActsAsTaggableOn::Tagging.table_name}.tag_id = #{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key} AND #{ActsAsTaggableOn::Tag.table_name}.name IN (?) AND #{ActsAsTaggableOn::Tagging.table_name}.context = ?", , context ]) end |