Topic: ruby has class scope not method scope, correct?
Hey all,
ruby has class scope not method scope, correct?
So in this class, for example:
class RestfulController
def extract_resource_model
resource_model_name
resource_model
end
def resource_model_name
#@resource_model_name ||= self.class.resource_model_name || controller_name.singularize
@resource_model_name ||= controller_name.singularize
end
def resource_model
@resource_model ||= Kernel.const_get(@resource_model_name.camelize)
end
end
when resource_model_name is called, resource_model_name returns an instance variable @resource_model_name as part of the return value in extract_resource_model method. Now that instance variable @resource_model_name is available throughout all the instance methods in that class, correct? That's why I am able to access it without any problems with scope resolution in resource_model, correct?
Thanks for response.