Skip to content

Commit

Permalink
Merge pull request #20 from bdunne/remove_object_namespace
Browse files Browse the repository at this point in the history
Remove Object#namespace
  • Loading branch information
Fryguy committed Oct 13, 2015
2 parents d45ca70 + f71201d commit b37c82b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
10 changes: 1 addition & 9 deletions lib/more_core_extensions/core_ext/object/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions spec/core_ext/object/namespace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b37c82b

Please sign in to comment.