module RailsAudioGlue::ControllerMethods
Provides the send_glued_audio
method for ApplicationController.
Constants
- GLUE_MIME_TYPES
Mapper for audio formats and mime types. If the format is unknown, it will generate it dynamically using a proc.
Public Instance Methods
send_glued_audio(template_name, variables = {})
click to toggle source
Assemble the audio using the passed template and variables. And send it as data.
@param template_name [String] name of template in app/audio_templates @param variables [Hash] instance variables to initiate template.
@return [void]
# File lib/rails_audio_glue/controller_methods.rb, line 23 def send_glued_audio(template_name, variables = {}) loader = RailsAudioGlue.loader builder = RailsAudioGlue.builder # Reset the cache in development so we don't need to restart the server # to see changes in the glue template. loader.reset_cache! if Rails.env.development? template = loader.get(template_name).new(variables) data = builder.build(template) format = template.format filename = "#{File.basename(template_name)}.#{format}" mime_type = GLUE_MIME_TYPES[format] send_data(data, :filename => filename, :type => mime_type) end