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

yawaraka zouzei

31bd6f01896a7c8f449b01bfa4bc1fe6?s=47 uvb_76
December 14, 2019

yawaraka zouzei

31bd6f01896a7c8f449b01bfa4bc1fe6?s=128

uvb_76

December 14, 2019
Tweet

Transcript

  1. ͸͡Ίͯͷ૿੫ରԠ "UTVTIJ,BUTVVSB(.01FQBCP *OD ฏ੒3VCZձٞ ΍ΘΒ͔૿੫

  2. ࠓ೔࿩͢͜ͱ w೥݄ͷফඅ੫૿੫ରԠͰ&$αʔϏεͰඞཁʹͳͬͨ͜ͱ w࣮ࡍʹରԠ͢Δ্ͰؾΛ͚ͭͨ͜ͱ w݄೔Λܴ͑ͨͱ͖ɺ͏·͍͔͘ͳ͔ͬͨ͜ͱ 3VCZͷ࿩͋·Γͳ͍Ͱ͢ɻੜ׆ൃදͰ͢ɻ

  3. উӜರJLBSVHB!67#@ (.0ϖύϘגࣜձࣾ&$ࣄۀ෦ΧϥʔϛʔϦϐʔτνʔϜ IUUQTJLBSVHBPSH

  4. IUUQTDPMPSNFSFQFBUKQ

  5. ΧϥʔϛʔϦϐʔτ w8FC"1*αʔόʔ 3VCZPO3BJMT  wϑϩϯτΤϯυαʔόʔ &YQSFTT 7VFKT  αϒεΫϦϓγϣϯͷܖ໿͕Ͱ͖ΔϥϯσΟϯάϖʔδΛ࡞Δ͜ͱ͕Ͱ ͖ΔαʔϏε

    ೥݄೔αʔϏεϦϦʔε⾣͸͡Ίͯͷ૿੫
  6. ૿੫

  7. &$αʔϏεʹऻ͍͔͔Δফඅ੫૿੫ wγϣοϓΦʔφʔͷαʔϏεར༻ྉͷফඅ੫ wγϣοϓΦʔφʔ͕ઃఆ͢Δ঎඼ͷফඅ੫ wܰݮ੫཰ͷઃఆΛؚΉ

  8. ܰݮ੫཰ wಛఆͷ঎඼͸੫཰͕͡Όͳͯ͘ʹͳΓ·͢Α wαʔϏεఏڙଆ͕൑அ͢Δ΋ͷͰ͸ͳ͘ɺʮγϣοϓ Φʔφʔʯ͕൑அ͢Δ΋ͷ wγϣοϓΦʔφʔʹ͓஌Βͤͯ͠ઃఆͯ͠໯͏ඞཁ͕ ͋Δ

  9. ૿੫ରԠͰ΍ͬͨ͜ͱ wαʔϏεར༻ྉͷফඅ੫૿੫ରԠ w঎඼ͷফඅ੫૿੫ରԠ wܰݮ੫཰ͷઃఆͷఏڙ ࣌ࠁΛڥʹදࣔΛ੾Γସ͑Δ  ࠓճ͸লུ w ૹྉͷ֎੫Խ w

    ாථͷमਖ਼ ۠෼هࡌ੥ٻॻ౳อଘํࣜ  w ച্కΊॲཧͷεϓϦΫτͷमਖ਼
  10. ੫཰͕ద༻͞ΕΔλΠϛϯά

  11. Ұ࣍ιʔεΛΑ͘ಡΉ

  12. ࠃ੫ி

  13. αʔϏεར༻ྉͷ੫཰ wલఏΧϥʔϛʔϦϐʔτͷαʔϏεར༻ྉ͸೔ԁ w݁࿦ܖ໿ऴྃ೔͕Ҏ߱ͷͱ͖ɺͷফඅ੫Ͱѻ͏ wࠃ੫ிͷ)1ΛΑΉ wIUUQTXXXOUBHPKQUBYFTTIJSBCFSVUBYBOTXFSTIPIJ IUN

  14.  ɹ໾຿ͷఏڙ ɹ੥ෛʹΑΔ໾຿ͷఏڙͷ࣌ظ͸ɺݪଇͱ͠ ͯɺ෺ͷҾ౉͠Λཁ͢Δ੥ෛܖ໿ʹ͋ͬͯ͸ ໨త෺ͷશ෦Λ׬੒ͯ͠Ҿ͖౉ͨ͠೔ɺ෺ͷ Ҿ౉͠Λཁ͠ͳ͍੥ෛܖ໿ʹ͋ͬͯ͸ͦͷ໿ ͨ͠໾຿ͷશ෦ͷఏڙΛ׬ྃͨ͠೔Ͱ͢ɻ ɹ·ͨɺ੥ෛΛআ͘ਓత໾຿ͷఏڙͷ࣌ظ ͸ɺݪଇͱͯͦ͠ͷਓత໾຿ͷఏڙΛ׬ྃ͠ ͨ೔Ͱ͢ɻ

  15.  ɹ໾຿ͷఏڙ ɹ੥ෛʹΑΔ໾຿ͷఏڙͷ࣌ظ͸ɺݪଇͱ͠ ͯɺ෺ͷҾ౉͠Λཁ͢Δ੥ෛܖ໿ʹ͋ͬͯ͸ ໨త෺ͷશ෦Λ׬੒ͯ͠Ҿ͖౉ͨ͠೔ɺ෺ͷ Ҿ౉͠Λཁ͠ͳ͍੥ෛܖ໿ʹ͋ͬͯ͸ͦͷ໿ ͨ͠໾຿ͷશ෦ͷఏڙΛ׬ྃͨ͠೔Ͱ͢ɻ ɹ·ͨɺ੥ෛΛআ͘ਓత໾຿ͷఏڙͷ࣌ظ ͸ɺݪଇͱͯͦ͠ͷਓత໾຿ͷఏڙΛ׬ྃ͠ ͨ೔Ͱ͢ɻ

  16. αʔϏεར༻ྉͷ੫཰ wܖ໿ΛͰදݱ͢Δͱ  ੫཰ U ੫཰ ੫཰ TUBSUFE@BU FOEFE@BU

  17. ঎඼Ձ֨ͷ੫཰͕ద༻͞ΕΔλΠϛϯά w݁࿦঎඼Ձ֨͸ൃૹ࣌ͷ੫཰Λద༻͢Δ wʹड஫ͨ͋͠ͱʹൃૹ w⾣ͷ੫཰͕ద༻͞ΕΔ wIUUQTXXXOUBHPKQMBXUTVUBUTVLJIPOTIPIJIUN ΛಡΉ

  18. ʵʵɹ୨Էࢿ࢈ͷҾ౉͠ͷ೔͕͍ͭͰ͋ Δ͔ʹ͍ͭͯ͸ɺྫ͑͹ɺग़ՙͨ͠೔ɺ૬ख ํ͕ݕऩͨ͠೔ɺ૬खํʹ͓͍ͯ࢖༻ऩӹ͕ Ͱ͖Δ͜ͱͱͳͬͨ೔ɺݕ਑౳ʹΑΓൢച਺ ྔΛ֬ೝͨ͠೔౳ɺ౰֘୨Էࢿ࢈ͷछྨٴͼ ੑ࣭ɺͦͷൢചʹ܎Δܖ໿ͷ಺༰౳ʹԠͯ͡ ͦͷҾ౉͠ͷ೔ͱͯ͠߹ཧతͰ͋ΔͱೝΊΒ ΕΔ೔ͷ͏ͪɺࣄۀऀ͕ܧଓͯ͠୨Էࢿ࢈ͷ ৡ౉Λߦͬͨ͜ͱͱ͍ͯ͠Δ೔ʹΑΔ΋ͷͱ ͢Δɻ

  19. ࣮૷

  20. ੫཰ΛͲ͏දݱ͢Δ͔ w੫཰͕ద༻͞ΕΔ࣌ࠁ wܰݮ੫཰͔Ͳ͏͔ ͕Θ͔Ε͹੫཰͸ٻΊΒΕͦ͏ wఆ਺Ͱઃఆʹ͢Δ  w%#ʹσʔλΛ΋ͨͤΔ

  21. %#Ͱ੫཰Λදݱ͍ͨ͠ "id" "kind" "rate" "started_at" "expired_at" "created_at" "updated_at" 1 0

    0.08 "2014-03-31 15:00:00" "2019-09-30 14:59:59.999999" "2019-07-16 09:44:39.516075" "2019-07-16 09:44:39.516075" 2 0 0.1 "2019-09-30 15:00:00" NULL "2019-07-16 09:44:39.519505" "2019-07-16 09:44:39.519505" 3 1 0.08 "2019-09-30 15:00:00" NULL "2019-07-16 09:44:39.521575" "2019-07-16 09:44:39.521575" UBYFTςʔϒϧര஀ ࠓճ͸ͪ͜ΒΛ࠾༻
  22. ࣮૷ class Tax < ApplicationRecord enum kind: { ordinary: 0,

    reduced: 1 } class << self def ordinary_rate(time = Time.current) # 10%ͷ੫཰༻ ordinary.where('started_at <= ?', time).order(started_at: :desc).first.rate end def reduced_rate(time = Time.current) # 8%(ܰݮ੫཰)༻ reduced.where('started_at <= ?', time).order(started_at: :desc).first.rate end end end
  23. UBYFTςʔϒϧͷ 4&-&$5͕΍ͨΒͱଟ͍

  24. %BUF5JNFΫϥε͸ϛϦඵ·Ͱ࣋ͬͯΔ [1] pry(main)> Time.current.iso8601(7) => "2019-12-09T08:49:24.4245084+09:00" 5JNFDVSSFOUΛ౉͢ͱ࣮ߦ͢ΔͨͼʹΫΤϦ͕࣮ߦ͞ΕΔͷͰ ΫΤϦΩϟογϡ͕ޮ͔ͳ͍ ੫཰ܭࢉͷج४೔࣌Λ໌֬ʹҾ਺ͱͯ͠౉͢͜ͱͰಉ͡ΫΤϦΛ ు͖ग़ͤ͞ɺΫΤϦΩϟογϡΛޮ͔͢

  25. IUUQTHJUIVCDPNDPMPSCPY TIPVIJ[FJ

  26. 4IPVIJ[FJ(FN w:BNMͰͷఆ਺ಡΈࠐΈ wܰݮ੫཰ରԠ w͜ͷࢿྉ࡞ͬͯΔ࠷தʹݟ௚ͯ͠ʮΑ͍ʜʯͱͳͬͨ irb(main):010:0> Shouhizei.rate_on(Time.current) => (1/10) irb(main):011:0> Shouhizei.rate_on(Time.current,

    reduced: true) => (2/25)
  27. Ͳ͕͍͍ͬͪͩΖ͏Ͷ w5BYʹґଘ͢Δ3FMBUJPO͸ଘࡏ͠ͳ͍ͷͰఆ਺Ͱ΋໰୊ͳ͍ wҰํͰফඅ੫཰ͱ͍͏σʔλΛ%#Ͱදݱ͢Δͷ΋ࣗવͰ͸͋Δ wґଘ(FN͸গͳ͍΄͏͕ྑ͍ ࠓճ͸ͲͬͪΛબΜͰ΋Α͔ͬͨͱࢥͬͨɻ

  28. ࣌ࠁΛڥʹදࣔΛ੾Γସ͑Δ

  29. ͳͥඞཁʹͳ͔ͬͨ wϑϩϯτΤϯυͰΛڥʹදࣔΛ੾Γସ͑ ͍ͨ w࣌ؒΛڥք஋ͱ͢Δςετ͸େม wͰ͖Δ͚ͩ୯७ʹݕূ͍ͨ͠

  30. Ͳ͏͔ͨ͠ w"1*ͷϨεϙϯεʹl૿੫ޙͷ৘ใ͔ zͲ͏͔ͷϨε ϙϯεΛCPPMͰ௥Ճͨ͠ w࣌ࠁΛฦͯ͠ϑϩϯτΤϯυͰ൑அ͢ΔͷΛආ͚ͨ

  31. "1*Ͱ࣌ࠁΛฦͯ͠΋ྑ͍ͷͰ͸ wl৘ใ͕࡞੒͞Εͨ࣌ࠁzͲ͏͔ͷϨεϙϯεΛ௥Ճ͢ ΔͱɺϑϩϯτΤϯυͰ΋࣌ࠁͷൺֱ͕ඞཁʹͳΔ wϑϩϯτΤϯυͷ࣌ࠁͷൺֱ͸େม

  32. ςετ

  33. 34QFDͰςετ࣌ࠁΛม͑Δ # spec/support/traveling.rb RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers config.around(:each, :travel_to)

    do |example| travel_to(example.metadata[:travel_to]) do example.run end end end
  34. 34QFDͰςετ࣌ࠁΛม͑Δ # spec/support/traveling.rb RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers config.around(:each, :travel_to)

    do |example| travel_to(example.metadata[:travel_to]) do example.run end end end IUUQTSFMJTIBQQDPNSTQFDSTQFD DPSFWEPDTIPPLTBSPVOE
  35. ࢖͍ํ ྫ context '૿੫લͷͱ͖', travel_to: '2019/09/30 23:59:59' do # ੫཰8%Ͱ͋Δ͜ͱΛ֬ೝ͢ΔςετΛ͜͜ʹ͔͘

    end wϒϩοΫͷதͰAUSBWFM@UPA͕ޮ͍ͯศར w !LBKJTIB͞ΜͷΞΠσΞͰ͢ɻ͋Γ͕ͱ͏͍͟͝·͢ɻ
  36. DPOUFYUͷ੾Γํ w૿੫લ૿੫ޙͰେ͖ͳίϯςΩετΛ੾Δ wͦΕͧΕʹطଘͷςετΛίϐϖ͢Δ w૿੫ޙͷίϯςΩετΛ௚͢ wςετ਺͸૿͑Δ͕ɺޙย෇͚ ςετͷ࡟আ ͷͱ͖૿੫લͷίϯς Ωετʹண໨ͯ͠ςετͷ੔ཧΛߦ͑͹ྑ͍ͷͰָ

  37. ૿੫ޙʹ͏·͍͔͘ͳ͔ͬͨ͜ͱ

  38. ͏·͍͔͘ͳ͔ͬͨ͜ͱ w૿੫ޙͷදࣔपΓͷෆ۩߹͸ग़ͯ͠·ͬͨ w"1*ͷςετ͕NBTUFSͰࣦഊ͢ΔΑ͏ʹͳ͍ͬͯͨ

  39. NBTUFSͰςετ͕ίέͩ͢ w૿੫લʹ͸QBTT͍ͯͨ͠ςετ͕ࣦഊͨ͠ w૿੫ޙͷमਖ਼࡞ۀʹӨڹ͕ग़ͨ wUSBWFM@UPͷઃఆ΋ΕͰ݄ʹ͸௨͍ͬͯͨςετ͕݄ʹࣦഊ͍ͯͨ͠ wϩʔΧϧͰະདྷ࣌ࠁʹมߋͯ͠ςετΛҰ౓௨ͨ͠΄͏͕Α͔ͬͨʜ

  40. ·ͱΊ wϑϩϯτΤϯυʹ͸࣌ࠁΛ౉ͣ͞ʹݟͤΔํ๏Λߟ͑Δ wมߋ͢Δ࣌ࠁ͝ͱʹίϯςΩετΛ࡞͓ͬͯ͘ͱޙָ͕ w๏཯ͷରԠ͸େม ँࣙ !LZNNUϨϏϡʔ͋Γ͕ͱ͏͍͟͝·ͨ͠