Module: MyTags::ActiveRecord
- Defined in:
- lib/my_tags/active_record.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#process_tags(tag_list) ⇒ Object
Add/Update tags for object @post.process_tags(‘cat, dog’) @post.process_tags().
- #tag_list ⇒ Object
- #tag_list=(names) ⇒ Object
Class Method Details
.included(base) ⇒ Object
2 3 4 |
# File 'lib/my_tags/active_record.rb', line 2 def self.included(base) base.extend MyTags::ActiveRecord::ClassMethods end |
Instance Method Details
#process_tags(tag_list) ⇒ Object
Add/Update tags for object @post.process_tags(‘cat, dog’) @post.process_tags()
17 18 19 20 |
# File 'lib/my_tags/active_record.rb', line 17 def (tag_list) tag_list = tag_list.split(',').map(&:strip) unless tag_list.is_a?(Array) self.tag_list = tag_list end |
#tag_list ⇒ Object
6 7 8 |
# File 'lib/my_tags/active_record.rb', line 6 def tag_list @tag_list ||= MyTags::TagList.new self end |
#tag_list=(names) ⇒ Object
10 11 12 |
# File 'lib/my_tags/active_record.rb', line 10 def tag_list=(names) @tag_names = names.is_a?(MyTags::TagList) ? names : MyTags::TagList.new_with_names(self, names) end |