Class: AntiSamy::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/antisamy/model/tag.rb

Overview

A model for HTML “tags” and the rules dictating their validation/filtration. Also contains information about their allowed attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Tag

Create a new Tag object



9
10
11
12
13
# File 'lib/antisamy/model/tag.rb', line 9

def initialize(name)
  @name = name
  @action = action
  @allowed_attributes = {}
end

Instance Attribute Details

#actionObject

Name and Action fields. Actions determine what we do when we see this tag



6
7
8
# File 'lib/antisamy/model/tag.rb', line 6

def action
  @action
end

#nameObject

Name and Action fields. Actions determine what we do when we see this tag



6
7
8
# File 'lib/antisamy/model/tag.rb', line 6

def name
  @name
end

Instance Method Details

#<<(attribute) ⇒ Object

Add an attribute to this property



16
17
18
# File 'lib/antisamy/model/tag.rb', line 16

def <<(attribute)
  @allowed_attributes[attribute.name.downcase] = attribute
end

#attribute(name) ⇒ Object

Fetch a property by name form this tag



26
27
28
# File 'lib/antisamy/model/tag.rb', line 26

def attribute(name)
  @allowed_attributes[name]
end

#attributesObject

fetch the map of attributes



21
22
23
# File 'lib/antisamy/model/tag.rb', line 21

def attributes
  @allowed_attributes
end