From f71201d86d12bb5fcff0adbc2972b8a77e1ca3f3 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Thu, 13 Aug 2015 11:31:18 -0400 Subject: [PATCH] Remove Object#namespace --- .../core_ext/object/namespace.rb | 10 +--------- spec/core_ext/object/namespace_spec.rb | 14 -------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/lib/more_core_extensions/core_ext/object/namespace.rb b/lib/more_core_extensions/core_ext/object/namespace.rb index 1003ccb..180b941 100644 --- a/lib/more_core_extensions/core_ext/object/namespace.rb +++ b/lib/more_core_extensions/core_ext/object/namespace.rb @@ -11,15 +11,7 @@ module ObjectNamespace # Aaa::Bbb::Ccc::Eee.in_namespace?(Aaa::Bbb::Ccc::Ddd) #=> false def in_namespace?(val) val_ns = val.to_s.split("::") - val_ns == namespace[0, val_ns.length] - end - - # - # Returns an Array with the namespace to an Instance. - # - # Aaa::Bbb::Ccc::Ddd.new.namespace #=> ["Aaa", "Bbb", "Ccc", "Ddd"] - def namespace - self.class.namespace + val_ns == (kind_of?(Module) ? namespace : self.class.namespace)[0, val_ns.length] end end end diff --git a/spec/core_ext/object/namespace_spec.rb b/spec/core_ext/object/namespace_spec.rb index 507cc15..c5a626c 100644 --- a/spec/core_ext/object/namespace_spec.rb +++ b/spec/core_ext/object/namespace_spec.rb @@ -27,18 +27,4 @@ module Eee; end expect(Aaa::Bbb::Ccc::Eee.in_namespace?(Aaa::Bbb::Ccc::Ddd)).to be_falsey end end - - context "namespace" do - it "Class in Module" do - expect(Aaa::Bbb::Ccc::Ddd.namespace).to eq(["Aaa", "Bbb", "Ccc", "Ddd"]) - end - - it "Module in Module" do - expect(Aaa::Bbb::Ccc::Eee.namespace).to eq(["Aaa", "Bbb", "Ccc", "Eee"]) - end - - it "Instance of a Class" do - expect(Aaa::Bbb::Ccc::Ddd.new.namespace).to eq(["Aaa", "Bbb", "Ccc", "Ddd"]) - end - end end