Class: Array

Inherits:
Object show all
Defined in:
lib/mongo_persist/array_ext.rb,
lib/mongo_persist/array_ext.rb

Instance Method Summary collapse

Instance Method Details

#can_mongo_convert?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/mongo_persist/array_ext.rb', line 11

def can_mongo_convert?
  all? { |x| x.can_mongo_convert? && x }
end

#sumObject



17
18
19
# File 'lib/mongo_persist/array_ext.rb', line 17

def sum
  inject { |s,i| s + i }
end

#to_mongo_hashObject



2
3
4
# File 'lib/mongo_persist/array_ext.rb', line 2

def to_mongo_hash
  map { |x| x.safe_to_mongo_hash }
end

#to_mongo_objectObject



5
6
7
# File 'lib/mongo_persist/array_ext.rb', line 5

def to_mongo_object
  map { |x| x.safe_to_mongo_object }
end

#to_mongo_ref_hashObject



8
9
10
# File 'lib/mongo_persist/array_ext.rb', line 8

def to_mongo_ref_hash
  map { |x| x.to_mongo_ref_hash }
end