private Method

Base.find_resource_in_modules(resource_name, module_names)

Tries to find a resource in a non empty list of nested modules Raises a NameError if it was not found in any of the given nested modules

Source Code

# File active_resource/base.rb, line 851
def find_resource_in_modules(resource_name, module_names)
  receiver = Object
  namespaces = module_names[0, module_names.size-1].map do |module_name|
    receiver = receiver.const_get(module_name)
  end
  if namespace = namespaces.reverse.detect { |ns| ns.const_defined?(resource_name) }
    return namespace.const_get(resource_name)
  else
    raise NameError
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.