Module: Genealogy::QueryMethods::ClassMethods

Defined in:
lib/genealogy/query_methods.rb

Instance Method Summary collapse

Instance Method Details

#all_with(role) ⇒ ActiveRecord, ActiveRecord::Relation

all individuals individuals having relative with specified role

Returns:

  • (ActiveRecord, ActiveRecord::Relation)

299
300
301
302
303
304
305
306
307
308
# File 'lib/genealogy/query_methods.rb', line 299

def all_with(role)
  case role
  when :father
    where('father_id is not ?',nil)
  when :mother
    where('mother_id is not ?',nil)
  when :parents
    where('father_id is not ? and mother_id is not ?',nil,nil)
  end
end

#femalesActiveRecord::Relation

all female individuals

Returns:

  • (ActiveRecord::Relation)

294
295
296
# File 'lib/genealogy/query_methods.rb', line 294

def females
  where(sex: sex_female_value)
end

#malesActiveRecord::Relation

all male individuals

Returns:

  • (ActiveRecord::Relation)

289
290
291
# File 'lib/genealogy/query_methods.rb', line 289

def males
  where(sex: sex_male_value)
end