LiveSourceLiveResolver

class Resolver

Resolves a client-side tag into a server-side instance.

Definitions

def self.allow(*arguments)

Creates an instance of the resolver, allowing the specified classes to be resolved.

Implementation

def self.allow(*arguments)
	self.new.allow(*arguments).freeze
end

def allow(*arguments)

Allow the specified classes to be resolved.

Implementation

def allow(*arguments)
	arguments.each do |klass|
		@allowed[klass.name] = klass
	end
	
	return self
end

attr :allowed

Signature

attribute Hash(String, Class)

A map of allowed class names.

def call(id, data)

Resolve a tag.

Signature

parameter id String

The unique identifier for the tag.

parameter data Hash

The data associated with the tag. Should include the :class key.

returns Element

The element instance if it was allowed.

Implementation

def call(id, data)
	if klass = @allowed[data[:class]]
		return klass.new(id, data)
	end
end