what does :: do in this case?

P

petermichaux

Hi

This is in the Rails acts_as_list module but I think is a general Ruby
question. I don't understand the syntax of the ::#{self.name}
statement. I haven't seen :: without something preceding it. I think I
understand what this method enables the plugin to do: use the class
name in which the module is mixed.

Thanks,
Peter



module ActiveRecord
module Acts
module List

def acts_as_list_class
::#{self.name}
end

end
end
end
 
A

Austin Ziegler

This is in the Rails acts_as_list module but I think is a general Ruby
question. I don't understand the syntax of the ::#{self.name}
statement. I haven't seen :: without something preceding it. I think I
understand what this method enables the plugin to do: use the class
name in which the module is mixed.

Unless that's in a section of string code to be evaled, that's
actually a syntax error. (The #{} syntax is only valid in strings).

However, if you do:

::File

You mean specifically that you want the File constant visible at the top le=
vel.

-austin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top