Class: LexxyVariables::Registry

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

Overview

Maps a chip's content-type to the attachment type that resolves it. Registering the same content-type again overrides the previous entry, so a host can replace a built-in type (e.g. variables) or add new ones (snippets). Nodes with no registered content-type (images, files, ...) match nothing and are left untouched by the pipeline.

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



8
9
10
# File 'lib/lexxy_variables/registry.rb', line 8

def initialize
  @by_content_type = {}
end

Instance Method Details

#match(node) ⇒ Object



16
17
18
# File 'lib/lexxy_variables/registry.rb', line 16

def match(node)
  @by_content_type[node["content-type"]]
end

#register(type) ⇒ Object



12
13
14
# File 'lib/lexxy_variables/registry.rb', line 12

def register(type)
  @by_content_type[type.content_type] = type
end

#typesObject



20
21
22
# File 'lib/lexxy_variables/registry.rb', line 20

def types
  @by_content_type.values
end