ruby - Debugging Object.const_get -


consider following code (i know have past 30 minutes):

[1] pry(main)> durhamscraper::tweet => durhamscraper::tweet [2] pry(main)> object.const_get("durhamscraper::tweet") nameerror: wrong constant name durhamscraper::tweet (pry):2:in 'const_get' [3] pry(main)> string => string [4] pry(main)> object.const_get("string") => string 

durhamscraper::tweet class loaded (as can infer line 1). no exceptions raised when ran code earlier. change when code executed changed repository name. advice on how debug further, or how may solve this?

per ruby 2.1.1 documentation: this method recursively constant names if namespaced class name provided.

the issue when changed directory's name, no longer using ruby 2.1.1 , instead using ruby 1.9.3. if object.const_get not work expect, make sure check ruby version , corresponding documentation.

for earlier versions of ruby not allow namespaced class names, can walk hierarchy, kardeiz suggested:

object.const_get(namespace).const_get(class) 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -