genealogy 2.6.4 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4018c3163fa6f6597b2c34e1b03c0f9fb489bd924f2005aaf4dd220809869deb
4
- data.tar.gz: 6577a730fe4448def2c650746a3bd582f8622b5f28a8f15a6d442729612f1afd
3
+ metadata.gz: 639bb06863d19cad4c662b7850f4e4bb543bb7f0b9fd5154816b0fda326056d8
4
+ data.tar.gz: e64f5b21c41397ee24f45591f81c651c0d876413dbb302586c8a8db147696805
5
5
  SHA512:
6
- metadata.gz: 53a20632af604fbc079e787d73f00d9f12f4c78d4df34fd5e6b80fb3ea0624c97c9cff1fabcd2e5eb2a0302ea59a493c7451b136ad0aefab2a7f607662100829
7
- data.tar.gz: 81b4228b4dc6b7ededc5caf5fd350b028a68519fdb98ac318fbd66354a8f89f290ce947b30418bfde2ceafd15318fe5da54c3d87488d599662e7486d53695389
6
+ metadata.gz: cb37b3ef1a4414dcd3d505102cdd05699663ed5d0da01e2d0fc26fe8364b6d03f377f3f132e226532089e7893e8051354f43690175b0fcdb7f78d7820483d233
7
+ data.tar.gz: 2e238f05371e623cc1de5318bbe3453c968d66f85edeb698f07fb5fe50f34f8b441c193ea73c4ee7bb6a56a3cfb11533ac06c60ad7fbc737d80fb358065751db
@@ -3,8 +3,6 @@ module Genealogy
3
3
  module AlterMethods
4
4
  extend ActiveSupport::Concern
5
5
 
6
- include Constants
7
-
8
6
  # @!macro [attach] generate
9
7
  # @method add_$1(parent)
10
8
  # Add $1
@@ -76,7 +74,7 @@ module Genealogy
76
74
  def self.generate_method_add_grandparent(lineage,grandparent)
77
75
  relationship = "#{lineage}_grand#{grandparent}"
78
76
  define_method "add_#{relationship}" do |gp|
79
- parent = LINEAGE2PARENT[lineage]
77
+ parent = gclass::LINEAGE2PARENT[lineage]
80
78
  raise_if_gap_on(parent)
81
79
  check_incompatible_relationship(relationship,gp)
82
80
  send(parent).send("add_#{grandparent}",gp)
@@ -95,7 +93,7 @@ module Genealogy
95
93
  def self.generate_method_remove_grandparent(lineage,grandparent)
96
94
  relationship = "#{lineage}_grand#{grandparent}"
97
95
  define_method "remove_#{relationship}" do
98
- parent = LINEAGE2PARENT[lineage]
96
+ parent = gclass::LINEAGE2PARENT[lineage]
99
97
  raise_if_gap_on(parent)
100
98
  send(parent).send("remove_#{grandparent}")
101
99
  end
@@ -115,7 +113,7 @@ module Genealogy
115
113
  def self.generate_method_add_grandparents_by_lineage(lineage)
116
114
  relationship = "#{lineage}_grandparents"
117
115
  define_method "add_#{relationship}" do |gf,gm|
118
- parent = LINEAGE2PARENT[lineage]
116
+ parent = gclass::LINEAGE2PARENT[lineage]
119
117
  raise_if_gap_on(parent)
120
118
  send(parent).send("add_parents",gf,gm)
121
119
  end
@@ -131,7 +129,7 @@ module Genealogy
131
129
  def self.generate_method_remove_grandparents_by_lineage(lineage)
132
130
  relationship = "#{lineage}_grandparents"
133
131
  define_method "remove_#{relationship}" do
134
- parent = LINEAGE2PARENT[lineage]
132
+ parent = gclass::LINEAGE2PARENT[lineage]
135
133
  raise_if_gap_on(parent)
136
134
  send(parent).send("remove_parents")
137
135
  end
@@ -1,7 +1,6 @@
1
1
  module Genealogy
2
2
  module ComplexQueryMethods
3
3
  extend ActiveSupport::Concern
4
- include Constants
5
4
 
6
5
  module ClassMethods
7
6
 
@@ -1,56 +1,61 @@
1
1
  module Genealogy
2
2
  module Constants
3
- # deafault options for has_parent method
4
- DEFAULTS = {
5
- column_names: {
6
- sex: 'sex',
7
- father_id: 'father_id',
8
- mother_id: 'mother_id',
9
- current_spouse_id: 'current_spouse_id',
10
- birth_date: 'birth_date',
11
- death_date: 'death_date'
12
- },
13
- perform_validation: true,
14
- ineligibility: :pedigree,
15
- current_spouse: false,
16
- sex_values: ['M','F'],
17
- limit_ages: {
18
- min_male_procreation_age: 12,
19
- max_male_procreation_age: 75,
20
- min_female_procreation_age: 9,
21
- max_female_procreation_age: 50,
22
- max_male_life_expectancy: 110,
23
- max_female_life_expectancy: 110
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |base|
6
+ # deafault options for has_parent method
7
+ base.const_set :DEFAULTS, {
8
+ column_names: {
9
+ sex: 'sex',
10
+ father_id: 'father_id',
11
+ mother_id: 'mother_id',
12
+ current_spouse_id: 'current_spouse_id',
13
+ birth_date: 'birth_date',
14
+ death_date: 'death_date'
15
+ },
16
+ perform_validation: true,
17
+ ineligibility: :pedigree,
18
+ current_spouse: false,
19
+ sex_values: ['M','F'],
20
+ limit_ages: {
21
+ min_male_procreation_age: 12,
22
+ max_male_procreation_age: 75,
23
+ min_female_procreation_age: 9,
24
+ max_female_procreation_age: 50,
25
+ max_male_life_expectancy: 110,
26
+ max_female_life_expectancy: 110
27
+ }
24
28
  }
25
- }
26
29
 
27
- # ineligibility levels
28
- PEDIGREE = 1
29
- PEDIGREE_AND_DATES = 2
30
- OFF = 0
30
+ # ineligibility levels
31
+ base.const_set :PEDIGREE, 1
32
+ base.const_set :PEDIGREE_AND_DATES, 2
33
+ base.const_set :OFF, 0
34
+
35
+ base.const_set :PARENT2LINEAGE, ActiveSupport::HashWithIndifferentAccess.new({ father: :paternal, mother: :maternal })
36
+ base.const_set :LINEAGE2PARENT, ActiveSupport::HashWithIndifferentAccess.new({ paternal: :father, maternal: :mother })
37
+ base.const_set :OPPOSITELINEAGE, ActiveSupport::HashWithIndifferentAccess.new({ paternal: :maternal, maternal: :paternal })
38
+ base.const_set :PARENT2SEX, ActiveSupport::HashWithIndifferentAccess.new({ father: :male, mother: :female })
39
+ base.const_set :SEX2PARENT, ActiveSupport::HashWithIndifferentAccess.new({ male: :father, female: :mother })
40
+ base.const_set :OPPOSITESEX, ActiveSupport::HashWithIndifferentAccess.new({male: :female, female: :male})
31
41
 
32
- PARENT2LINEAGE = ActiveSupport::HashWithIndifferentAccess.new({ father: :paternal, mother: :maternal })
33
- LINEAGE2PARENT = ActiveSupport::HashWithIndifferentAccess.new({ paternal: :father, maternal: :mother })
34
- OPPOSITELINEAGE = ActiveSupport::HashWithIndifferentAccess.new({ paternal: :maternal, maternal: :paternal })
35
- PARENT2SEX = ActiveSupport::HashWithIndifferentAccess.new({ father: :male, mother: :female })
36
- SEX2PARENT = ActiveSupport::HashWithIndifferentAccess.new({ male: :father, female: :mother })
37
- OPPOSITESEX = ActiveSupport::HashWithIndifferentAccess.new({male: :female, female: :male})
42
+ base.const_set :AKA, ActiveSupport::HashWithIndifferentAccess.new({
43
+ father: "F",
44
+ mother: "M",
45
+ paternal_grandfather: "PGF",
46
+ paternal_grandmother: "PGM",
47
+ maternal_grandfather: "MGF",
48
+ maternal_grandmother: "MGM",
49
+ children: "C",
50
+ siblings: "S",
51
+ half_siblings: "HS",
52
+ paternal_half_siblings: "PHS",
53
+ maternal_half_siblings: "MHS",
54
+ grandchildren: "GC",
55
+ uncles_and_aunts: "U&A",
56
+ nieces_and_nephews: "N&N"
57
+ })
38
58
 
39
- AKA = ActiveSupport::HashWithIndifferentAccess.new({
40
- father: "F",
41
- mother: "M",
42
- paternal_grandfather: "PGF",
43
- paternal_grandmother: "PGM",
44
- maternal_grandfather: "MGF",
45
- maternal_grandmother: "MGM",
46
- children: "C",
47
- siblings: "S",
48
- half_siblings: "HS",
49
- paternal_half_siblings: "PHS",
50
- maternal_half_siblings: "MHS",
51
- grandchildren: "GC",
52
- uncles_and_aunts: "U&A",
53
- nieces_and_nephews: "N&N"
54
- })
59
+ end
55
60
  end
56
61
  end
@@ -3,8 +3,6 @@ module Genealogy
3
3
  module CurrentSpouseMethods
4
4
  extend ActiveSupport::Concern
5
5
 
6
- include Constants
7
-
8
6
  # add current spouse updating receiver and argument individuals foreign_key in a transaction
9
7
  # @param [Object] spouse
10
8
  # @return [Boolean]
@@ -2,9 +2,7 @@ module Genealogy
2
2
 
3
3
  extend ActiveSupport::Concern
4
4
 
5
- module ClassMethods
6
-
7
- include Genealogy::Constants
5
+ class_methods do
8
6
 
9
7
  # gives to ActiveRecord model geneaogy capabilities. Modules UtilMethods QueryMethods IneligibleMethods AlterMethods and SpouseMethods are included
10
8
  # @param [Hash] options
@@ -22,16 +20,19 @@ module Genealogy
22
20
 
23
21
  def has_parents options = {}
24
22
 
25
- include Genealogy::UtilMethods
26
- include Genealogy::QueryMethods
27
- include Genealogy::ComplexQueryMethods
28
- include Genealogy::IneligibleMethods
29
- include Genealogy::AlterMethods
30
- include Genealogy::CurrentSpouseMethods
31
-
23
+ include Constants
24
+ include UtilMethods
25
+ include QueryMethods
26
+ include ComplexQueryMethods
27
+ include IneligibleMethods
28
+ include AlterMethods
29
+ include CurrentSpouseMethods
32
30
 
33
31
  check_has_parents_options(options)
34
32
 
33
+ # instance_variable_set(:@role_as_relative, nil)
34
+ attr_accessor :role_as_relative
35
+
35
36
  # keep track of the original extend class to prevent wrong scopes in query method in case of STI
36
37
  class_attribute :gclass, instance_writer: false
37
38
  self.gclass = self
@@ -43,22 +44,22 @@ module Genealogy
43
44
  class_attribute :ineligibility_level, instance_accessor: false
44
45
  self.ineligibility_level = case options[:ineligibility]
45
46
  when :pedigree
46
- PEDIGREE
47
+ gclass::PEDIGREE
47
48
  when true
48
- PEDIGREE
49
+ gclass::PEDIGREE
49
50
  when :pedigree_and_dates
50
- PEDIGREE_AND_DATES
51
+ gclass::PEDIGREE_AND_DATES
51
52
  when false
52
- OFF
53
+ gclass::OFF
53
54
  when nil
54
- PEDIGREE
55
+ gclass::PEDIGREE
55
56
  else
56
57
  raise ArgumentError, "ineligibility option must be one among :pedigree, :pedigree_and_dates or false"
57
58
  end
58
59
 
59
60
  ## limit_ages
60
- if ineligibility_level >= PEDIGREE_AND_DATES
61
- DEFAULTS[:limit_ages].each do |age,v|
61
+ if ineligibility_level >= gclass::PEDIGREE_AND_DATES
62
+ gclass::DEFAULTS[:limit_ages].each do |age,v|
62
63
  class_attribute age, instance_accessor: false
63
64
  self.send("#{age}=", options[:limit_ages].try(:[],age) || v)
64
65
  end
@@ -67,12 +68,12 @@ module Genealogy
67
68
  [:current_spouse, :perform_validation].each do |opt|
68
69
  ca = "#{opt}_enabled"
69
70
  class_attribute ca, instance_accessor: false
70
- self.send "#{ca}=", options.key?(opt) ? options[opt] : DEFAULTS[opt]
71
+ self.send "#{ca}=", options.key?(opt) ? options[opt] : gclass::DEFAULTS[opt]
71
72
  end
72
73
 
73
74
 
74
75
  # column names class attributes
75
- DEFAULTS[:column_names].merge(options[:column_names]).each do |k,v|
76
+ gclass::DEFAULTS[:column_names].merge(options[:column_names]).each do |k,v|
76
77
  class_attribute_name = "#{k}_column"
77
78
  class_attribute class_attribute_name, instance_accessor: false
78
79
  self.send("#{class_attribute_name}=", v)
@@ -81,7 +82,7 @@ module Genealogy
81
82
 
82
83
  ## sex
83
84
  class_attribute :sex_values, :sex_male_value, :sex_female_value, instance_accessor: false
84
- self.sex_values = options[:sex_values] || DEFAULTS[:sex_values]
85
+ self.sex_values = options[:sex_values] || gclass::DEFAULTS[:sex_values]
85
86
  self.sex_male_value = self.sex_values.first
86
87
  self.sex_female_value = self.sex_values.last
87
88
 
@@ -4,8 +4,6 @@ module Genealogy
4
4
  module IneligibleMethods
5
5
  extend ActiveSupport::Concern
6
6
 
7
- include Constants
8
-
9
7
  # @!macro [attach] generate_method_ineligibles_parent_with_docs
10
8
  # @method ineligible_$1s
11
9
  # list of individual who cannot be $1 according to the ineligibility level in use.
@@ -16,8 +14,8 @@ module Genealogy
16
14
  define_method "ineligible_#{parent_role}s" do
17
15
  unless self.send(parent_role)
18
16
  ineligibles = []
19
- ineligibles |= descendants | [self] | gclass.send("#{unexpected_sex}s") if gclass.ineligibility_level >= PEDIGREE
20
- if gclass.ineligibility_level >= PEDIGREE_AND_DATES and birth_range
17
+ ineligibles |= descendants | [self] | gclass.send("#{unexpected_sex}s") if gclass.ineligibility_level >= gclass::PEDIGREE
18
+ if gclass.ineligibility_level >= gclass::PEDIGREE_AND_DATES and birth_range
21
19
  ineligibles |= (gclass.all - ineligibles).find_all do |indiv|
22
20
  !indiv.can_procreate_during?(birth_range)
23
21
  end
@@ -43,9 +41,9 @@ module Genealogy
43
41
  ineligibles = []
44
42
  if parent = send(parent_role)
45
43
  ineligibles |= parent.send("ineligible_#{grandparent2parent_role}s")
46
- elsif gclass.ineligibility_level >= PEDIGREE
44
+ elsif gclass.ineligibility_level >= gclass::PEDIGREE
47
45
  ineligibles |= descendants | siblings | [self] | gclass.send("#{unexpected_sex}s")
48
- if gclass.ineligibility_level >= PEDIGREE_AND_DATES
46
+ if gclass.ineligibility_level >= gclass::PEDIGREE_AND_DATES
49
47
  ineligibles |= (gclass.all - ineligibles).find_all do |indiv|
50
48
  !indiv.can_procreate_during?(send("#{parent_role}_birth_range"))
51
49
  end
@@ -67,8 +65,8 @@ module Genealogy
67
65
  # @return [Array]
68
66
  def ineligible_children
69
67
  ineligibles = []
70
- ineligibles |= ancestors | children | siblings | [self] | gclass.all_with(SEX2PARENT[ssex]) if gclass.ineligibility_level >= PEDIGREE
71
- if gclass.ineligibility_level >= PEDIGREE_AND_DATES and fertility_range
68
+ ineligibles |= ancestors | children | siblings | [self] | gclass.all_with(gclass::SEX2PARENT[ssex]) if gclass.ineligibility_level >= gclass::PEDIGREE
69
+ if gclass.ineligibility_level >= gclass::PEDIGREE_AND_DATES and fertility_range
72
70
  ineligibles |= (gclass.all - ineligibles).find_all{ |indiv| !can_procreate_during?(indiv.birth_range)}
73
71
  end
74
72
  ineligibles
@@ -81,12 +79,12 @@ module Genealogy
81
79
  # @return [Array]
82
80
  def ineligible_siblings
83
81
  ineligibles = []
84
- if gclass.ineligibility_level >= PEDIGREE
82
+ if gclass.ineligibility_level >= gclass::PEDIGREE
85
83
  ineligibles |= ancestors | descendants | siblings | [self]
86
84
  ineligibles |= (father ? gclass.all_with(:father).where("father_id != ?", father) : [])
87
85
  ineligibles |= (mother ? gclass.all_with(:mother).where("mother_id != ?", mother) : [])
88
86
  end
89
- if gclass.ineligibility_level >= PEDIGREE_AND_DATES
87
+ if gclass.ineligibility_level >= gclass::PEDIGREE_AND_DATES
90
88
  [:father,:mother].each do |parent|
91
89
  if p = send(parent)
92
90
  # if a parent is present ineligible siblings are parent's ineligible children
@@ -118,14 +116,14 @@ module Genealogy
118
116
  def self.generate_method_ineligibles_half_siblings_with_docs(lineage,parent_role)
119
117
  define_method "ineligible_#{lineage}_half_siblings" do
120
118
  ineligibles = []
121
- parent = LINEAGE2PARENT[lineage]
119
+ parent = gclass::LINEAGE2PARENT[lineage]
122
120
  p = send(parent)
123
- if gclass.ineligibility_level >= PEDIGREE
121
+ if gclass.ineligibility_level >= gclass::PEDIGREE
124
122
  ineligibles |= p.ineligible_children
125
- ineligibles |= send("#{OPPOSITELINEAGE[lineage]}_half_siblings") # other lineage half siblings would become full siblings so they cannot be current lineage half sibling
123
+ ineligibles |= send("#{gclass::OPPOSITELINEAGE[lineage]}_half_siblings") # other lineage half siblings would become full siblings so they cannot be current lineage half sibling
126
124
  ineligibles |= gclass.all_with(parent)
127
125
  end
128
- if gclass.ineligibility_level >= PEDIGREE_AND_DATES
126
+ if gclass.ineligibility_level >= gclass::PEDIGREE_AND_DATES
129
127
  if p
130
128
  # if a parent is present ineligible siblings are parent's ineligible children
131
129
  ineligibles |= p.ineligible_children
@@ -3,8 +3,6 @@ module Genealogy
3
3
  module QueryMethods
4
4
  extend ActiveSupport::Concern
5
5
 
6
- include Constants
7
-
8
6
  # @return [2-elements Array] father and mother
9
7
  def parents
10
8
  [father,mother]
@@ -51,17 +49,17 @@ module Genealogy
51
49
  # @return [ActiveRecord::Relation] children
52
50
  def children(options = {})
53
51
  raise SexError, "Sex value not valid for #{self}. It's needed to look for children" unless gclass.sex_values.include? sex_before_type_cast
54
- result = gclass.where("#{SEX2PARENT[ssex]}_id" => self)
52
+ result = gclass.where("#{gclass::SEX2PARENT[ssex]}_id" => self)
55
53
  if options.keys.include? :spouse
56
54
  check_indiv(spouse = options[:spouse],opposite_ssex)
57
- result = result.where("#{SEX2PARENT[opposite_ssex]}_id" => spouse ) if spouse
55
+ result = result.where("#{gclass::SEX2PARENT[opposite_ssex]}_id" => spouse ) if spouse
58
56
  end
59
57
  result
60
58
  end
61
59
 
62
60
  # @return [ActiveRecord::Relation] list of individuals with whom has had children
63
61
  def spouses
64
- gclass.where(id: children.pluck("#{SEX2PARENT[opposite_ssex]}_id".to_sym).compact.uniq) | (self.class.current_spouse_enabled ? [] : [current_spouse])
62
+ gclass.where(id: children.pluck("#{gclass::SEX2PARENT[opposite_ssex]}_id".to_sym).compact.uniq) | (self.class.current_spouse_enabled ? [] : [current_spouse])
65
63
  end
66
64
 
67
65
  # @param [Hash] options
@@ -275,6 +273,7 @@ module Genealogy
275
273
  # family hash with roles as keys? :spouse and individuals as values. Defaults roles are :father, :mother, :children, :siblings and current_spouse if enabled
276
274
  # @option options [Symbol] half to filter siblings (see #siblings)
277
275
  # @option options [Boolean] extended to include roles for grandparents, grandchildren, uncles, aunts, nieces, nephews and cousins
276
+ # @option options [Boolean] singular_role to use singularized role as keys
278
277
  # @return [Hash] family hash with roles as keys? :spouse and individuals as values.
279
278
  def family_hash(options = {})
280
279
  roles = [:father, :mother, :children, :siblings]
@@ -294,7 +293,42 @@ module Genealogy
294
293
  raise ArgumentError, "Admitted values for :half options are: :father, :mother, :include, :include_separately, nil"
295
294
  end
296
295
  roles += [:paternal_grandfather, :paternal_grandmother, :maternal_grandfather, :maternal_grandmother, :grandchildren, :uncles_and_aunts, :nieces_and_nephews, :cousins] if options[:extended] == true
297
- roles.inject({}){|res,role| res.merge!({role => self.send(role)})}
296
+ res = roles.inject({}){|res,role| res.merge!({role => self.send(role)})}
297
+ if options[:singular_role] == true
298
+ res2 = {
299
+ father: res[:father],
300
+ mother: res[:mother],
301
+ daughter: res[:children].females,
302
+ son: res[:children].males,
303
+ sister: res[:siblings].females,
304
+ brother: res[:siblings].males
305
+ }
306
+
307
+ res2[:current_spouse] = res[:current_spouse] if res.has_key? :current_spouse
308
+
309
+ res2.merge!({
310
+ paternal_grandfather: res[:paternal_grandfather],
311
+ paternal_grandmother: res[:paternal_grandmother],
312
+ maternal_grandfather: res[:maternal_grandfather],
313
+ maternal_grandmother: res[:maternal_grandmother],
314
+ grandchild: res[:grandchildren],
315
+ uncle: res[:uncles_and_aunts].males,
316
+ aunts: res[:uncles_and_aunts].females,
317
+ nephew: res[:nieces_and_nephews].males,
318
+ niece: res[:nieces_and_nephews].females,
319
+ cousin: res[:cousins]
320
+ }) if options[:extended] == true
321
+
322
+ res2.merge!({
323
+ paternal_half_brother: res[:paternal_half_siblings].males,
324
+ paternal_half_sister: res[:paternal_half_siblings].females,
325
+ maternal_half_brother: res[:maternal_half_siblings].males,
326
+ maternal_half_sister: res[:maternal_half_siblings].females,
327
+ }) if options[:half] == :include_separately
328
+
329
+ res = res2
330
+ end
331
+ res
298
332
  end
299
333
 
300
334
  # family_hash with option extended: :true
@@ -307,8 +341,13 @@ module Genealogy
307
341
  # @return [Array]
308
342
  # @see #family_hash
309
343
  def family(options = {})
310
- hash = family_hash(options)
311
- hash.keys.inject([]){|tot,k| tot << hash[k] }.compact.flatten
344
+ family_hash(options).inject([]) do |memo, r|
345
+ [r.last].compact.flatten.each do |relative|
346
+ relative.role_as_relative = r.first.to_s.singularize.to_sym
347
+ memo << relative
348
+ end
349
+ memo
350
+ end
312
351
  end
313
352
 
314
353
  # family with option extended: :true
@@ -3,8 +3,6 @@ module Genealogy
3
3
  module UtilMethods
4
4
  extend ActiveSupport::Concern
5
5
 
6
- include Constants
7
-
8
6
  # Genealogy thinks time in term of Date, not DateTime
9
7
  # @return [Date]
10
8
  def birth
@@ -80,9 +78,9 @@ module Genealogy
80
78
  def self.generate_method_parent_birth_range(parent)
81
79
  define_method "#{parent}_birth_range" do
82
80
  if birth
83
- (birth - gclass.send("max_#{PARENT2SEX[parent]}_procreation_age").years)..(birth - gclass.send("min_#{PARENT2SEX[parent]}_procreation_age").years)
81
+ (birth - gclass.send("max_#{gclass::PARENT2SEX[parent]}_procreation_age").years)..(birth - gclass.send("min_#{gclass::PARENT2SEX[parent]}_procreation_age").years)
84
82
  elsif life_range
85
- (life_range.begin - gclass.send("max_#{PARENT2SEX[parent]}_procreation_age").years)..(life_range.end - gclass.send("min_#{PARENT2SEX[parent]}_procreation_age").years)
83
+ (life_range.begin - gclass.send("max_#{gclass::PARENT2SEX[parent]}_procreation_age").years)..(life_range.end - gclass.send("min_#{gclass::PARENT2SEX[parent]}_procreation_age").years)
86
84
  end
87
85
  end
88
86
  end
@@ -96,7 +94,7 @@ module Genealogy
96
94
  def self.generate_method_parent_fertility_range(parent)
97
95
  define_method "#{parent}_fertility_range" do
98
96
  if parent_birth_range = send("#{parent}_birth_range")
99
- (parent_birth_range.begin + gclass.send("min_#{PARENT2SEX[parent]}_procreation_age").years)..(parent_birth_range.end + gclass.send("max_#{PARENT2SEX[parent]}_procreation_age").years)
97
+ (parent_birth_range.begin + gclass.send("min_#{gclass::PARENT2SEX[parent]}_procreation_age").years)..(parent_birth_range.end + gclass.send("max_#{gclass::PARENT2SEX[parent]}_procreation_age").years)
100
98
  end
101
99
  end
102
100
  end
@@ -119,7 +117,7 @@ module Genealogy
119
117
  # opposite sex in terms of :male or :female
120
118
  # @return [Symbol]
121
119
  def opposite_ssex
122
- OPPOSITESEX[ssex]
120
+ gclass::OPPOSITESEX[ssex]
123
121
  end
124
122
 
125
123
  # @return [Boolean]
@@ -160,7 +158,7 @@ module Genealogy
160
158
  # puts "[#{__method__}]: #{arg} class: #{arg.class}, #{self} class: #{self.class}"
161
159
  next if relative.nil?
162
160
  check_indiv(relative)
163
- if gclass.ineligibility_level >= PEDIGREE
161
+ if gclass.ineligibility_level >= gclass::PEDIGREE
164
162
  if ineligibles = self.send("ineligible_#{relationship.to_s.pluralize}")
165
163
  # puts "[#{__method__}]: checking if #{relative} can be #{relationship} of #{self}"
166
164
  raise IncompatibleRelationshipException, "#{relative} can't be #{relationship} of #{self}" if ineligibles.include? relative
@@ -1,3 +1,3 @@
1
1
  module Genealogy
2
- VERSION = "2.6.4"
2
+ VERSION = "2.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genealogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.4
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - masciugo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2020-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  - !ruby/object:Gem::Version
273
273
  version: '0'
274
274
  requirements: []
275
- rubygems_version: 3.0.3
275
+ rubygems_version: 3.1.2
276
276
  signing_key:
277
277
  specification_version: 4
278
278
  summary: Make ActiveRecord model act as a pedigree