class Notification

Public Class Methods

create_notification(template_name, locals = {}) click to toggle source
# File lib/generators/acts_as_notificable/templates/notification.rb, line 15
def self.create_notification(template_name, locals = {})
  Notification.create(template_name: template_name, locals: locals)
end

Public Instance Methods

render(options = {}) click to toggle source
# File lib/generators/acts_as_notificable/templates/notification.rb, line 8
def render(options = {})
  locals.merge!(notification: self)
  render_options = { file: "notifications/#{template_name}", locals: locals }
  render_options[:layout] = "layouts/" + options[:layout] if options.has_key?(:layout)
  view.render(render_options)
end

Private Instance Methods

view() click to toggle source
# File lib/generators/acts_as_notificable/templates/notification.rb, line 20
def view
  view_paths = ActionController::Base.view_paths
  @_view ||= Class.new(ActionView::Base) do
    include Rails.application.routes.url_helpers
  end.new(view_paths, {})
end