Method: ActiveFedora::FinderMethods#find

Defined in:
lib/active_fedora/relation/finder_methods.rb

#find(*args) ⇒ Array

Returns objects of the Class that find is being called on.

Options Hash (*args):

  • :rows (Integer)

    when :all is passed, the maximum number of rows to load from solr

  • :cast (Boolean)

    when true, examine the model and cast it to the first known cModel

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/active_fedora/relation/finder_methods.rb', line 32

def find(*args)
  return to_a.find { |*block_args| yield(*block_args) } if block_given?
  options = args.extract_options!
  options = options.dup
  cast = if @klass == ActiveFedora::Base && !options.key?(:cast)
           true
         else
           options.delete(:cast)
         end
  if options[:sort]
    # Deprecate sort sometime?
    sort = options.delete(:sort)
    options[:order] ||= sort if sort.present?
  end

  raise ArgumentError, "#{self}.find() expects an id. You provided `#{args.inspect}'" unless args.is_a? Array
  find_with_ids(args, cast)
end