Class: Models::Tags
- Inherits:
-
Array
- Object
- Array
- Models::Tags
- Defined in:
- lib/kit/models/tags.rb
Defined Under Namespace
Classes: ContextTags
Instance Attribute Summary collapse
-
#_changes ⇒ Object
Updating Tag and counts cache.
Instance Method Summary collapse
- #as_string ⇒ Object
-
#initialize(array = nil) ⇒ Tags
constructor
A new instance of Tags.
- #topic ⇒ Object
- #topic=(value) ⇒ Object
Constructor Details
#initialize(array = nil) ⇒ Tags
Returns a new instance of Tags.
4 5 6 7 |
# File 'lib/kit/models/tags.rb', line 4 def initialize array = nil super() replace array if array end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &b) ⇒ Object (protected)
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kit/models/tags.rb', line 42 def method_missing m, *args, &b if m !~ /=$/ context = m.to_s args.size.must == 0 {|tag| tag =~ /#{context}:/} else context = m.to_s[0..-2] args.size.must == 1 value = args.first (value){|tag| tag =~ /#{context}:/} end end |
Instance Attribute Details
#_changes ⇒ Object
Updating Tag and counts cache
28 29 30 |
# File 'lib/kit/models/tags.rb', line 28 def _changes @_changes end |
Instance Method Details
#as_string ⇒ Object
23 |
# File 'lib/kit/models/tags.rb', line 23 def as_string; join(", ") end |
#topic ⇒ Object
16 17 18 |
# File 'lib/kit/models/tags.rb', line 16 def topic {|tag| tag !~ /:/} end |
#topic=(value) ⇒ Object
19 20 21 |
# File 'lib/kit/models/tags.rb', line 19 def topic= value (value){|tag| tag !~ /:/} end |