class Fedora::Repository

def find_objects(*args)

-
find_objects("label=Image1", :include => [:label])
find_objects("label=Image1", :include => :all)
find_objects("pid~demo:*", "label=test")
find_objects("label=Image1")
== Examples

The field "pid" is always included.
select:: the fields to returned. To include all fields, pass :all as the value.
limit:: set the maxResults parameter in fedora
== Options keys

options:: see below
query:: the query string to be sent to Fedora.
== Parameters

Find fedora objects with http://www.fedora.info/wiki/index.php/API-A-Lite_findObjects
def find_objects(*args)
  raise ArgumentError, "Missing query string" unless args.length >= 1
  options = args.last.is_a?(Hash) ? args.pop : {}
  
  fields = options[:select]
  fields = (fields.nil? || (fields == :all)) ? ALL_FIELDS : ([:pid] + ([fields].flatten! - [:pid]))
  
  query = args.join(' ')
  params = { :resultFormat => 'xml', :query => query }
  params[:maxResults] = options[:limit] if options[:limit]
  params[:sessionToken] = options[:sessionToken] if options[:sessionToken]
  includes = fields.inject("") { |s, f| s += "&#{f}=true"; s }
  
  convert_xml(connection.get("#{fedora_url.path}/objects?#{params.to_fedora_query}#{includes}"))
end