module Sidekiq::WebCustom::WebAction
Constants
- OVERWRITE_VALUE
Public Class Methods
local_erbs()
click to toggle source
# File lib/sidekiq/web_custom/web_action.rb, line 8 def self.local_erbs @local_erbs ||= "#{File.expand_path("#{File.dirname(__FILE__)}/..")}/views" end
Public Instance Methods
erb(content, options = {})
click to toggle source
Calls superclass method
# File lib/sidekiq/web_custom/web_action.rb, line 12 def erb(content, options = {}) if content.is_a?(Symbol) && !Sidekiq::WebCustom.local_erb_mapping[content].nil? unless respond_to?(:"_erb_#{content}") file_name = Sidekiq::WebCustom.local_erb_mapping[content] src = ERB.new(src_file_replacement(content)).src WebAction.class_eval("def _erb_#{content}\n#{src}\n end", file_name) end end super(content, options) end
src_file_replacement(content)
click to toggle source
# File lib/sidekiq/web_custom/web_action.rb, line 23 def src_file_replacement(content) file_name = Sidekiq::WebCustom.local_erb_mapping[content] contents = File.read(file_name) begin available_actions = Sidekiq::WebCustom.config.public_send("actions_for_#{content}") rescue NoMethodError available_actions = [] end actions = available_actions.map do |action, action_path| File.read(action_path) end.join(" ") contents.gsub(OVERWRITE_VALUE, actions) end