Module: ActsAsTaggableOn::Taggable::Related
- Defined in:
- lib/acts_as_taggable_on/acts_as_taggable_on/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
3 4 5 6 |
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/related.rb', line 3 def self.included(base) base.extend ActsAsTaggableOn::Taggable::Related::ClassMethods base. end |
Instance Method Details
#find_matching_contexts(search_context, result_context, options = {}) ⇒ Object
30 31 32 |
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/related.rb', line 30 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
34 35 36 |
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/related.rb', line 34 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
38 39 40 41 |
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/related.rb', line 38 def matching_contexts_for(search_context, result_context, klass, = {}) = (search_context).collect { |t| t.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.to_s}' 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
43 44 45 46 47 |
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/related.rb', line 43 def (context, klass, = {}) = Array.wrap(.delete(:ignore)).map(&:to_s) || [] = (context).collect { |t| t.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.to_s}' AND #{ActsAsTaggableOn::Tagging.table_name}.tag_id = #{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key} AND #{ActsAsTaggableOn::Tag.table_name}.name IN (?)", ]) end |