space with de fi nitions in the space Namespace Application Code App::Func User Library Code DB::Client (v2) Library Code ActiveSupport (v7) Namespace Library Code DB::Client (v3) Namespace Application Code App::Func2 User Library Code ActiveSupport (v6) Application Code call call call
Namespaceͷ֎Ͱແޮʹ͍ͨ͠ • ಛఆͷൣғͰͷΈ༗ޮͳϝιου → Re fi nementsͰ? # my_awesome.rb class String def blank?; false; end end class MyAwesome def self.call; “yay”.blank?; end end # app.rb ns = Namespace.new ns.require(‘my_awesome’) ns::MyAwesome.call() #=> false “yay”.blank? # NoMethodError
= Namespace.new ns.require(‘my_awesome’) ns::MyAwesome.call() “yay”.blank? # NoMethodError # my_awesome.rb class String def blank?; false; end end class MyAwesome def self.call = “yay”.blank? end # my_awesome.rb using ns.refiner class String def blank?; false; end end class MyAwesome def self.call = “yay”.blank? end • Namespace෦ʹϞδϡʔϧ(re fi ner)ΛͬͯImplicit Re fi nementsʹ༻͍Δ • NamespaceͰධՁ͞ΕΔ .rb ·ͣ ҉ʹusing͞ΕΔ ಈ࡞͕ಁաతʹ ॻ͖͑ΒΕΔ෦
= Namespace.new ns.require(‘my_awesome’) ns::MyAwesome.call() “yay”.blank? # NoMethodError rb false; end me ll = “yay”.blank? # my_awesome.rb using ns.refiner module ns.refiner refine String do def blank?; false; end end end class MyAwesome def self.call = “yay”.blank? end # my_awesome.rb using ns.refiner class String def blank?; false; end end class MyAwesome def self.call = “yay”.blank? end • class StringΛ module re fi ner; re fi ne String ʹॻ͖͑ͯ Re fi nementʹͳΔΑ͏ಡΈସ͑Δ ಈ࡞͕ಁաతʹ ॻ͖͑ΒΕΔ෦
= Namespace.new ns.require(‘my_awesome’) ns::MyAwesome.call() “yay”.blank? # NoMethodError # my_awesome.rb using ns.refiner module ns.refiner refine String do def blank?; false; end end end using ns.refiner class MyAwesome def self.call = “yay”.blank? end # my_awesome.rb using ns.refiner module ns.refiner refine String do def blank?; false; end end end class MyAwesome def self.call = “yay”.blank? end y_awesome.rb ng ns.refiner ss String ef blank?; false; end ss MyAwesome ef self.call = “yay”.blank? • ߋ৽͞ΕͨRe fi nementΛ༗ޮʹ͢ΔͨΊ ͏͍ͪͲusing͢Δ ಈ࡞͕ಁաతʹ ॻ͖͑ΒΕΔ෦