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)

374
375
376
377
378
379
380
381
382
383
# File 'lib/genealogy/query_methods.rb', line 374

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)

369
370
371
# File 'lib/genealogy/query_methods.rb', line 369

def females
  where(sex: sex_female_value)
end

#malesActiveRecord::Relation

all male individuals

Returns:

  • (ActiveRecord::Relation)

364
365
366
# File 'lib/genealogy/query_methods.rb', line 364

def males
  where(sex: sex_male_value)
end