Sha256: b054c8152309c1042fd485658e3e535bd352034f5e0c2b21afaaa3ff52341b49
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require "sidekiq/web/helpers" require "sidekiq/web/action" module Sidekiq module WebActionHelper class ERB < ::ERB def initialize(content) replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {} replace_views.each do |key, content_blocks| next if WebRoute.new("", key, true).match("", self.class.path_info).nil? content_blocks.each do |content_block| content_block.call(content) end end super end class << self attr_accessor :path_info end end def erb(content, options = {}) ERB.path_info = ::Rack::Utils.unescape(env["PATH_INFO"]) super end def self.change_layout(&block) Sidekiq::Config::DEFAULTS[:layout_changes] ||= [] Sidekiq::Config::DEFAULTS[:layout_changes] << block end def _render content = super layout_changes = Sidekiq::Config::DEFAULTS[:layout_changes] || [] layout_changes.each do |content_block| content_block.call(content) end content end end Sidekiq::WebAction.prepend(Sidekiq::WebActionHelper) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-belt-1.0.0 | lib/sidekiq/web_action_helper.rb |
sidekiq-belt-0.3.7 | lib/sidekiq/web_action_helper.rb |
sidekiq-belt-0.3.6 | lib/sidekiq/web_action_helper.rb |