Module: Fortitude::Tags::TagStore

Included in:
Doctypes::Base, Doctypes::Html4TagsFrameset, Doctypes::Html4TagsStrict, Doctypes::Html4TagsTransitional
Defined in:
lib/fortitude/tags/tag_store.rb

Instance Method Summary collapse

Instance Method Details

#delegate_tag_storesObject



52
53
54
# File 'lib/fortitude/tags/tag_store.rb', line 52

def delegate_tag_stores
  [ ]
end

#modify_tag(name) {|new_tag| ... } ⇒ Object

Yields:

  • (new_tag)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fortitude/tags/tag_store.rb', line 17

def modify_tag(name)
  name = Fortitude::Tags::Tag.normalize_tag_name(name)
  existing_tag = tags[name]

  unless existing_tag
    raise Fortitude::Errors::TagNotFound.new(self, name)
  end

  new_tag = existing_tag.dup
  yield new_tag
  @_tags_by_name ||= { }
  @_tags_by_name[name] = new_tag

  tags_changed!([ new_tag ])
end

#tag(name, options = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/fortitude/tags/tag_store.rb', line 7

def tag(name, options = nil)
  @_tags_by_name ||= { }

  name = Fortitude::Tags::Tag.normalize_tag_name(name)
  tag_object = Fortitude::Tags::Tag.new(name, options || { })
  @_tags_by_name[name] = tag_object

  tags_added!([ tag_object ])
end

#tag_namesObject



40
41
42
# File 'lib/fortitude/tags/tag_store.rb', line 40

def tag_names
  tags.keys
end

#tagsObject



33
34
35
36
37
38
# File 'lib/fortitude/tags/tag_store.rb', line 33

def tags
  out = { }
  (delegate_tag_stores || [ ]).each { |d| out.merge!(d.tags) }
  out.merge!(@_tags_by_name || { })
  out
end

#tags_added!(tags) ⇒ Object



44
45
46
# File 'lib/fortitude/tags/tag_store.rb', line 44

def tags_added!(tags)
  tags_changed!(tags)
end

#tags_changed!(tags) ⇒ Object



48
49
50
# File 'lib/fortitude/tags/tag_store.rb', line 48

def tags_changed!(tags)
  # nothing here
end