Class: Medie::Registry

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

Instance Method Summary collapse

Instance Method Details

#<<(what) ⇒ Object

adds a new handler to this registry



5
6
7
# File 'lib/medie/registry.rb', line 5

def <<(what)
  use(what)
end

#for(media_type) ⇒ Object

Returns a handler that can handle this kind of media type. It will always use the last registered handler.



17
18
19
20
21
# File 'lib/medie/registry.rb', line 17

def for(media_type)
  registry.reverse.find do |handler|
    handler.can_handle?(media_type)
  end
end

#use(what) ⇒ Object

adds a new handler to this registry



10
11
12
13
# File 'lib/medie/registry.rb', line 10

def use(what)
  registry << what
  self
end