Module: DHS::Record::Find::ClassMethods
- Defined in:
- lib/dhs/concerns/record/find.rb
Instance Method Summary collapse
-
#find(*args) ⇒ Object
Find a single uniqe record.
Instance Method Details
#find(*args) ⇒ Object
Find a single uniqe record
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dhs/concerns/record/find.rb', line 12 def find(*args) args, = process_args(args) = trace!() raise(DHS::Unprocessable.new, 'Cannot find Record without an ID') if args.blank? && !args.is_a?(Array) data = if args.present? && args.is_a?(Array) find_in_parallel(args, ) elsif args.is_a? Hash find_with_parameters(args, ) else find_by_id(args, ) end return nil if data.nil? return data unless data._record if data.collection? data.map { |record| data._record.new(record.unwrap_nested_item) } else data._record.new(data.unwrap_nested_item) end end |