Class: RocketTag::Taggable::Manager
- Inherits:
-
Object
- Object
- RocketTag::Taggable::Manager
- Defined in:
- lib/rocket_tag/taggable.rb
Instance Attribute Summary collapse
-
#contexts ⇒ Object
Returns the value of attribute contexts.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(klass) ⇒ Manager
constructor
A new instance of Manager.
- #setup_relations ⇒ Object
Constructor Details
#initialize(klass) ⇒ Manager
Returns a new instance of Manager.
34 35 36 37 38 |
# File 'lib/rocket_tag/taggable.rb', line 34 def initialize klass @klass = klass @contexts = Set.new setup_relations end |
Instance Attribute Details
#contexts ⇒ Object
Returns the value of attribute contexts.
12 13 14 |
# File 'lib/rocket_tag/taggable.rb', line 12 def contexts @contexts end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
14 15 16 |
# File 'lib/rocket_tag/taggable.rb', line 14 def klass @klass end |
Class Method Details
.parse_tags(list) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rocket_tag/taggable.rb', line 16 def self. list require 'csv' if list.kind_of? String # for some reason CSV parser cannot handle # # hello, "foo" # # but must be # # hello,"foo" list = list.gsub /,\s+"/, ',"' list = list.parse_csv.map &:strip else list end end |
Instance Method Details
#setup_relations ⇒ Object
40 41 42 43 |
# File 'lib/rocket_tag/taggable.rb', line 40 def setup_relations klass.has_many :taggings , :dependent => :destroy , :as => :taggable, :class_name => "RocketTag::Tagging" klass.has_many :tags , :source => :tag, :through => :taggings, :class_name => "RocketTag::Tag" end |