module IRails::Display::Registry
Constants
- SUPPORTED_MIMES
Public Instance Methods
format(mime = nil, &block)
click to toggle source
# File lib/irails/display.rb, line 150 def format(mime = nil, &block) renderer << Renderer.new(@match, mime, block, @priority) renderer.sort_by! {|r| -r.priority } # Decrease priority implicitly for all formats # which are added later for a type. # Overwrite with the `priority` method! @priority -= 1 nil end
match(&block)
click to toggle source
# File lib/irails/display.rb, line 123 def match(&block) @match = block priority 0 nil end
priority(p)
click to toggle source
# File lib/irails/display.rb, line 145 def priority(p) @priority = p nil end
renderer()
click to toggle source
# File lib/irails/display.rb, line 109 def renderer @renderer ||= [] end
respond_to(name)
click to toggle source
# File lib/irails/display.rb, line 129 def respond_to(name) match {|obj| obj.respond_to?(name) } end
type(&block)
click to toggle source
# File lib/irails/display.rb, line 133 def type(&block) match do |obj| begin block.call === obj # We have to rescue all exceptions since constant autoloading could fail with a different error rescue Exception rescue #NameError false end end end