Class: Object

Inherits:
BasicObject
Defined in:
lib/smooth.rb

Instance Method Summary collapse

Instance Method Details

#Smooth(api_or_resource_name = nil) ⇒ Object

Provides a global helper for looking up things in the Smooth object system.

Example:

Smooth() #=> returns the current api
Smooth('books') #=> returns the books resource
Smooth('books.create') #=> returns the create command, for the books resource


236
237
238
239
240
241
242
243
244
# File 'lib/smooth.rb', line 236

def Smooth(api_or_resource_name = nil)
  return Smooth.current_api if api_or_resource_name.nil?

  if api_or_resource_name.to_s.include?(Smooth.config.object_path_separator)
    return Smooth.current_api.lookup_object_by(api_or_resource_name)
  end

  Smooth.fetch_api(api_or_resource_name) || Smooth.current_api.resource(api_or_resource_name)
end