UpdateAdhoqToSupportRails5

8f39a252784d5a99589be6e20c4553fb?s=47 takkanm
August 29, 2016

 UpdateAdhoqToSupportRails5

SpeeeCoffeeMeetup#01 で LT した話

8f39a252784d5a99589be6e20c4553fb?s=128

takkanm

August 29, 2016
Tweet

Transcript

  1. 3BJMT&OHJOFΛ 3BJMTʹରԠͤͨ͞࿩ ࡾଜӹོ !UBLLBON

  2. BCPVU.F w &JXB4ZTUFN.BOBHFNFOU w "TBLVTBSC w ύʔϑΣΫτ3VCZࣥචϝϯόʔͷҰਓ

  3. $PGGFF؀ڥ w ϛϧ͸ΧϦλͷύʔϑΣΫτλον w ՈͷυϦούʔ͸ϋϦΦ7 w ձࣾͰ͸ΤΞϩϓϨοι w ౾͸ΦϒεΩϡϥ͞Μͷίʔώʔఆظศ

  4. ຊ୊

  5. "EIPR w IUUQTHJUIVCDPNFTNJODBEIPR w 3BJMTΞϓϦέʔγϣϯʹ೚ҙͷΫΤϦΛ౤͛Ε ΔΑ͏ʹ͢ΔͨΊͷFOHJOF w ΫΤϦΛอଘͨ͠Γɺ݁ՌΛ೚ҙͷϑΥʔϚο τʹͯ͠ग़ྗ͢Δ͜ͱ͕Ͱ͖Δ

  6. "EIPR

  7. "EIPRϢʔεέʔε w ूܭΫΤϦͷಈ࡞֬ೝ w ఆظతʹಛఆͷूܭΛཔ·Εͨ࣌ʹΫΤϦΛอ ଘͯ͠࢖ͬͯ΋Β͏ w ো֐ରԠ౳Ͱσʔλͷ֬ೝΛߦ͏ࡍʹ

  8. IUUQTHJUIVCDPN FTNJODBEIPRQVMM w 3BJMT͕ϦϦʔε͞ΕͨޙʹૹΒΕ͖ͯͨରԠ QVMMSFRVFTU w ͦͷ··Ͱ͸Ϛʔδͮ͠Β͔ͬͨͨΊɺ࡞ऀʹ मਖ਼Λґཔ͕ͨ͠ରԠ͞Εͣ

  9. ࠓ೔ͷςʔϚ 3BJMTͰಈ࡞͠ͳ͍3BJMTFOHJOFΛ աڈͷόʔδϣϯͰͷಈ࡞Λอͪͭͭ Ξοϓσʔτ͓ͤͨ͞࿩ IUUQTHJUIVCDPNFTNJODBEIPRQVMM

  10. 3BJMTͰಈ࡞[ͤ͞ΔͨΊʹ ରԠͨ͜͠ͱ w IJEEFO@BDUJPO w "DUJPO$POUSPMMFS1BSBNFUFSTͷมߋ௥ ै w 3BJMTɹʹ޲͚ͯͷXBSOJOH࡟আ

  11. IJEEFO@BDUJPO w 3BJMT͔Β͸IJEEFO@BDUJPOͱ͍͏ϝιου ͕࡟আ͞ΕͨJOOPDFODF w IJEEFO@BDUJPO͸ίϯτϩʔϥʔͷϝιου ΛΞΫγϣϯͱͯ͠ݟͤͳ͘͢ΔͨΊͷϝιο υ

  12. มߋલ # 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
  13. มߋޙ # 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
  14. "DUJPO$POUSPMMFS1BSB NFUFSTͷมߋ௥ै w 3BJMTͰ"DUJPO$POUSPMMFS1BSBNFUFST ͕)BTIΛܧঝ͠ͳ͘ͳͬͨ w "DUJPO$POUSPMMFS1BSBNFUFSTͷΦϒδ ΣΫτΛͦͷ··"DUJWF+PCͷύϥϝʔλʔʹ ೖΕ͍ͯΔՕॴ͕͋ͬͨ

  15. มߋલ 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
  16. มߋޙ 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
  17. 3BJMT΁޲͚ͯͷ XBSOJOH࡟আ w CFGPSF@pMUFSΛCFGPSF@BDUJPO w DPOpHͷॻ͖ํมߋ UFTU  w UJNFܕΧϥϜͷڍಈΛܾఆ

    UFTU
  18. دΓಓɿXJDLFE@QEGʹߦ ͬͨ3BJMTରԠ w BMJBTF@NFUIPE@DIBJOΛQSFQFOEFEΛ ࢖͏Α͏ʹ w IUUQTHJUIVCDPNNJMFT[T XJDLFE@QEGQVMMpMFT

  19. มߋલ 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
  20. มߋલ 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
  21. ࠓޙͷͨΊʹ w ςετϚτϦοΫεͷ௥Ճ w FEHF3BJMTͱ࠷৽ͷ3VCZͷόʔδϣϯ ௥Ճ w αϙʔτόʔδϣϯͷมߋ w 3BJMTެࣜͱαϙʔτόʔδϣϯ͋Θͤͨ

  22. ·ͱΊ w ޙํޓ׵ੜΛอͪͳ͕Β௥ਵ͢Δͷେม w ಈ͍ͯͳͯ͘΋͍͍͔Β֬ೝͰ͖Δ؀ڥ͸༻ ҙ͓ͯ͜͠͏ w ͪΌΜͱಈ͘Α͏ʹͳͬͨͷͰؾʹͳͬͨํ ͸BEIPR࢖ͬͯΈ͍ͯͩ͘͞