Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UpdateAdhoqToSupportRails5

takkanm
August 29, 2016

 UpdateAdhoqToSupportRails5

SpeeeCoffeeMeetup#01 で LT した話

takkanm

August 29, 2016
Tweet

More Decks by takkanm

Other Decks in Technology

Transcript

  1. มߋલ # app/controllers/adhoq/authorization_methods.rb module Adhoq module AuthorizationMethods extend ActiveSupport::Concern included

    do |controller| controller.before_filter Authorizer.new helper_method :adhoq_current_user hide_action :adhoq_current_user end def adhoq_current_user end end end
  2. มߋޙ # app/controllers/adhoq/authorization_methods.rb module Adhoq module AuthorizationMethods extend ActiveSupport::Concern included

    do |controller| controller.before_filter Authorizer.new helper_method :adhoq_current_user end private def adhoq_current_user end end end
  3. มߋલ w  module Adhoq class ExecutionsController < Adhoq::ApplicationController def

    asynced_create Adhoq::ExecuteJob.perform_later(current_query, params[:execution][:report_format], query_parameters) redirect_to current_query end def query_parameters params[:parameters] || HashWithIndifferentAccess.new end end end
  4. มߋޙ def query_parameters if params[:parameters] if params[:parameters].kind_of?(Hash) params[:parameters] else #

    for after Rails5 params[:parameters].to_unsafe_hash end else HashWithIndifferentAccess.new end end
  5. มߋલ w  module PdfHelper def self.included(base) # Protect from

    trying to augment modules that appear # as the result of adding other gems. return if base != ActionController::Base base.class_eval do alias_method_chain :render, :wicked_pdf alias_method_chain :render_to_string, :wicked_pdf after_filter :clean_temp_files end end end
  6. มߋલ w  module PdfHelper def self.prepended(base) # Protect from

    trying to augment modules that appear # as the result of adding other gems. return if base != ActionController::Base base.class_eval do after_action :clean_temp_files alias_method :render_without_wicked_pdf, :render alias_method :render_to_string_without_wicked_pdf, :render_to_string def render(options = nil, *args, &block) render_with_wicked_pdf(options, *args, &block) end def render_to_string(options = nil, *args, &block) render_to_string_with_wicked_pdf(options, *args, &block) end end end end