Class: ApiView::Registry

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

Class Method Summary collapse

Class Method Details

.add_model(model, converter) ⇒ Object



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

def add_model(model, converter)
  models[model.to_s] = converter
end

.converter_for(clazz, options = nil) ⇒ Object



12
13
14
15
16
17
# File 'lib/api_view/registry.rb', line 12

def converter_for(clazz, options=nil)
  if options && options[:use].kind_of?(Class) then
    return options[:use]
  end
  models[clazz.to_s] || ApiView::Default
end

.modelsObject



4
5
6
# File 'lib/api_view/registry.rb', line 4

def models
  @models ||= {}
end