我有一个包含变量的哈希值:
module Categories
module Services
PHOTOGRAPHY_VIDEO = "9115"
end
end
hash = {"CatId" => Categories::Services::PHOTOGRAPHY_VIDEO}
puts(hash["CatId"]) # This returns "9115" but how do I get the "Services" category?
我想向Ruby询问'CatId'的变量'value'等于'Services'的命名空间。我想做这样的事情:
def priced?
(hash["CatId"]).unknown_method == Services
end
如何获取它的命名空间?