Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# Renders an object using to registered transform method based on the # negotiated content-type, if a template does not exist. For instance, if the # content-type is :json, Merb will first look for current_action.json.*. # Failing that, it will run object.to_json. # # ==== Parameter # object<Object>:: # An object that responds_to? the transform method registered for the # negotiated mime-type. # thing<String, Symbol>:: # The thing to attempt to render via #render before calling the transform # method on the object. Defaults to nil. # opts<Hash>:: # An options hash that will be used for rendering # (passed on to #render or serialization methods like #to_json or #to_xml) # # ==== Returns # String:: # The rendered template or if no template is found, the transformed object. # # ==== Raises # NotAcceptable:: # If there is no transform method for the specified mime-type or the object # does not respond to the transform method. # # ==== Alternatives # A string in the second parameter will be interpreted as a template: # display @object, "path/to/foo" # #=> display @object, nil, :template => "path/to/foo" # # A hash in the second parameters will be interpreted as opts: # display @object, :layout => "zoo" # #=> display @object, nil, :layout => "zoo" # # If you need to pass extra parameters to serialization method, for instance, # to exclude some of attributes or serialize associations, just pass options # for it. # For instance, # # display @locations, :except => [:locatable_type, :locatable_id], :include => [:locatable] # # serializes object with polymorphic association, not raw locatable_* attributes. # # # ==== Options # # :template a template to use for rendering # :layout a layout to use for rendering # all other options options that will be pass to serialization method # like #to_json or #to_xml # # ==== Notes # The transformed object will not be used in a layout unless a :layout is # explicitly passed in the opts. # def display(object, thing = nil, opts = {})
This paste will be private.
From the Design Piracy series on my blog: