genealogy 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDUxMWM3YjI0ZjM3MjU0Y2NhMGQ4Zjc3OTBiNjNiOGEwY2M5YzQ0NQ==
5
+ data.tar.gz: !binary |-
6
+ ZDEyYjgxMDE5OWQ5ODQ5ODEyZjg5YWRlMDMwYTkxZmQzMjE4NjIxMw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OWQ3YzhmZmUxM2RkYjYwZGFjNmNjYWJkMWEwNTBhNjBjNTdjMmFhMDhjNjQ4
10
+ ZTA3ZGZiMjhjZWQ3Mzk1YzE0YzIwNWZkMGI3ZTcxYTZiNjMyYzU0Y2RjNDc1
11
+ YTI2MGYxYjMzNzBkMGE2MzQ0ZGZlZDcyYmMxMjZmZjU5YTQyMmI=
12
+ data.tar.gz: !binary |-
13
+ MTFmYzc4NTRiMjVkNzkwZjNlNmEyMGMzOTY5Nzk3ZjYyYmMyMWU1MjUyZDU1
14
+ YmIyYzZmMTkxOTc1Mjk0YzQyMWE5YzlhMjc4OWMzYjM0MmFmYjczNjc5YTA4
15
+ NjBhMjI4ZjgwYzY1NThkMDVjZGJhNmRlZjlkMGFhOGYyMmU4NDM=
@@ -13,14 +13,22 @@ module Genealogy
13
13
  raise IncompatibleRelationshipException, "#{relative} can't be #{parent} of #{self}" if incompatible_parents.include? relative
14
14
  raise WrongSexException, "Can't add a #{relative.sex} #{parent}" unless (parent == :father and relative.is_male?) or (parent == :mother and relative.is_female?)
15
15
  end
16
- self.send("#{parent}=",relative)
17
- save!
16
+ if perform_validation
17
+ self.send("#{parent}=",relative)
18
+ save!
19
+ else
20
+ self.update_attribute(parent,relative)
21
+ end
18
22
  end
19
23
 
20
24
  # remove method
21
25
  define_method "remove_#{parent}" do
22
- self.send("#{parent}=",nil)
23
- save!
26
+ if perform_validation
27
+ self.send("#{parent}=",nil)
28
+ save!
29
+ else
30
+ self.update_attribute(parent,nil)
31
+ end
24
32
  end
25
33
 
26
34
  end
@@ -19,17 +19,18 @@ module Genealogy
19
19
 
20
20
  def has_parents options = {}
21
21
 
22
- admitted_keys = [:sex_column, :sex_values, :father_column, :mother_column, :current_spouse_column, :current_spouse]
22
+ admitted_keys = [:sex_column, :sex_values, :father_column, :mother_column, :current_spouse_column, :current_spouse, :perform_validation]
23
23
  check_options(options, admitted_keys) do |key, value|
24
24
  if key == :sex_values
25
25
  raise WrongOptionException, ":sex_values option must be an array with two char: first for male sex symbol an last for female" unless value.is_a?(Array) and value.size == 2 and value.first.to_s.size == 1 and value.last.to_s.size == 1
26
26
  end
27
27
  end
28
28
 
29
- class_attribute :genealogy_enabled, :current_spouse_enabled, :genealogy_class
29
+ class_attribute :genealogy_enabled, :current_spouse_enabled, :genealogy_class, :perform_validation
30
30
  self.genealogy_enabled = true
31
- self.current_spouse_enabled = options[:current_spouse].try(:==,true) || false
32
- self.genealogy_class = self #keep track of the original extend class to prevent wrong scopes in query method in case of STI
31
+ self.current_spouse_enabled = options[:current_spouse].try(:==,true) || false # default false
32
+ self.genealogy_class = self # keep track of the original extend class to prevent wrong scopes in query method in case of STI
33
+ self.perform_validation = options[:perform_validation].try(:==,false) ? false : true # default true
33
34
 
34
35
  tracked_relatives = [:father, :mother]
35
36
  tracked_relatives << :current_spouse if current_spouse_enabled
@@ -6,22 +6,38 @@ module Genealogy
6
6
  def add_current_spouse(obj)
7
7
  raise IncompatibleObjectException, "Linked objects must be instances of the same class" unless obj.is_a? self.genealogy_class
8
8
  raise WrongSexException, "Can't add current_spouse with same sex" if self.sex == obj.sex
9
- self.current_spouse = obj
10
- obj.current_spouse = self
11
- transaction do
12
- obj.save!
13
- save!
9
+
10
+ if perform_validation
11
+ self.current_spouse = obj
12
+ obj.current_spouse = self
13
+ transaction do
14
+ obj.save!
15
+ save!
16
+ end
17
+ else
18
+ transaction do
19
+ self.update_attribute(:current_spouse,obj)
20
+ obj.update_attribute(:current_spouse,self)
21
+ end
14
22
  end
23
+
15
24
  end
16
25
 
17
26
  # remove method
18
27
  def remove_current_spouse
19
- transaction do
28
+ if perform_validation
20
29
  ex_current_spouse = current_spouse
21
30
  current_spouse.current_spouse = nil
22
31
  self.current_spouse = nil
23
- ex_current_spouse.save!
24
- save!
32
+ transaction do
33
+ ex_current_spouse.save!
34
+ save!
35
+ end
36
+ else
37
+ transaction do
38
+ current_spouse.update_attribute(:current_spouse,nil)
39
+ self.update_attribute(:current_spouse,nil)
40
+ end
25
41
  end
26
42
  end
27
43
 
@@ -1,3 +1,3 @@
1
1
  module Genealogy
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genealogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - masciugo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: sqlite3
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: debugger
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: gem-release
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -142,26 +127,25 @@ files:
142
127
  homepage: https://github.com/masciugo/genealogy
143
128
  licenses:
144
129
  - MIT
130
+ metadata: {}
145
131
  post_install_message:
146
132
  rdoc_options: []
147
133
  require_paths:
148
134
  - lib
149
135
  required_ruby_version: !ruby/object:Gem::Requirement
150
- none: false
151
136
  requirements:
152
137
  - - ! '>='
153
138
  - !ruby/object:Gem::Version
154
139
  version: '0'
155
140
  required_rubygems_version: !ruby/object:Gem::Requirement
156
- none: false
157
141
  requirements:
158
142
  - - ! '>='
159
143
  - !ruby/object:Gem::Version
160
144
  version: '0'
161
145
  requirements: []
162
146
  rubyforge_project: ! '[none]'
163
- rubygems_version: 1.8.23
147
+ rubygems_version: 2.3.0
164
148
  signing_key:
165
- specification_version: 3
149
+ specification_version: 4
166
150
  summary: Organise ActiveRecord models into a genealogical tree structure
167
151
  test_files: []