Module: ActsAsTaggableOnMongoid::Tagger::TagMethods
- Defined in:
- lib/acts_as_taggable_on_mongoid/tagger/tag_methods.rb
Overview
:reek:DataClump
Class Method Summary collapse
Instance Method Summary collapse
-
#tag(taggable, *args) ⇒ Object
Taggs the passed in taggable object with the tag values passed in to it.
-
#tag!(taggable, *args) ⇒ Object
tag, but uses ‘save!` instead of `save` to save the taggable model.
Class Method Details
.atom_extract_tag_options(set_list) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/acts_as_taggable_on_mongoid/tagger/tag_methods.rb', line 39 def self.(set_list) = set_list. .assert_valid_keys :with, :on, :replace, :parse, :parser, :skip_save [:parse] = .fetch(:parse) { true } || .key?(:parser) end |
Instance Method Details
#tag(taggable, *args) ⇒ Object
Taggs the passed in taggable object with the tag values passed in to it.
Parameters:
taggable - the object to tag
non-hash values - the values to use to tag taggable with
{options}
with: - Alternative to non-hash values. If found as an option it will replace
any non-hash values. If not specified, any tags for this tagger will be
removed from taggable
on: - the tag list within taggable to be set. This will default to `:tag`
parse: - Boolean indicating if the tags should be parsed. This will default to "true"
parser: - Class to be used to parse the values.
skip_save: - Do not save the taggable object with the new tagging.
25 26 27 28 29 |
# File 'lib/acts_as_taggable_on_mongoid/tagger/tag_methods.rb', line 25 def tag(taggable, *args) = atom_tag(taggable, *args) taggable.save unless [:skip_save] end |
#tag!(taggable, *args) ⇒ Object
tag, but uses ‘save!` instead of `save` to save the taggable model.
33 34 35 36 37 |
# File 'lib/acts_as_taggable_on_mongoid/tagger/tag_methods.rb', line 33 def tag!(taggable, *args) = atom_tag(taggable, *args) taggable.save! unless [:skip_save] end |