Class: Merb::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/merb_meta.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(klass) ⇒ Object

Default any subclasses meta tags to that of the parent



8
9
10
11
# File 'lib/merb_meta.rb', line 8

def inherited(klass)
  orig_inherited(klass)
  klass.meta(self.meta)
end

.meta(tags = nil) ⇒ Object

Setter/Getter for meta Tags

Parameters:

  • tags (Hash|Symbol|Nil) (defaults to: nil)

    Hash => Sets the given meta tags NilClass => Returns the full hash of meta tags Symbol => Returns the specific meta tag



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/merb_meta.rb', line 21

def meta(tags = nil)
  @meta_tags ||={}
  
  if tags.is_a? Hash
    @meta_tags.merge!(tags) 
  elsif tags.is_a? Symbol
    return @meta_tags[tags]
  end

  @meta_tags
end

.orig_inheritedObject



6
# File 'lib/merb_meta.rb', line 6

alias :orig_inherited :inherited

Instance Method Details

#meta(tags = nil) ⇒ Object

Getter/Setter for a controller instance’s meta tags

Parameters:

  • tags (Hash|NilClass|Symbol) (defaults to: nil)

    Hash => Sets the given meta tags NilClass => Outputs the HTML Symbol => Returns the specific meta tag



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/merb_meta.rb', line 44

def meta(tags = nil)
  @meta_tags ||= self.class.meta.clone

  if tags.is_a? Hash
    @meta_tags.merge!(tags)
    @meta_tags
  elsif tags.is_a? Symbol
    return @meta_tags[tags]
  else
    output_meta_tags @meta_tags
  end
end