lib/ruby-fs-stack/familytree.rb in ruby-fs-stack-0.3.2 vs lib/ruby-fs-stack/familytree.rb in ruby-fs-stack-0.3.3
- old
+ new
@@ -563,10 +563,25 @@
def add_assertions!
self.assertions ||= RelationshipAssertions.new
end
end
+ class FamilyReference
+ def select_spouse(spouse_id)
+ add_parents!
+ self.action = 'Select'
+ parent = PersonReference.new
+ parent.id = spouse_id
+ self.parents << parent
+ end
+
+ private
+ def add_parents!
+ self.parents ||= []
+ end
+ end
+
class ParentsReference
def select_parent(parent_id, gender)
add_parents!
self.action = 'Select'
parent = PersonReference.new
@@ -864,10 +879,29 @@
couple = parents[0] || ParentsReference.new
couple.select_parent(person_id,'Male')
parents << couple
end
+ # Select the spouse for the summary view. This should be called on a Person record that
+ # contains a person id and version.
+ #
+ # ====Params
+ # <tt>person_id</tt> - the person id of the spouse that you would like to set as the summary
+ #
+ # ===Example
+ # person = com.familytree_v2.person 'KWQS-BBR', :names => 'none', :genders => 'none', :events => 'none'
+ # person.select_spouse_summary('KWQS-BBQ')
+ # com.familytree_v2.save_person person
+ #
+ # This is the recommended approach, to start with a "Version" person (no names, genders, or events)
+ def select_spouse_summary(person_id)
+ add_families!
+ family = FamilyReference.new
+ family.select_spouse(person_id)
+ families << family
+ end
+
def baptisms
select_ordinances('Baptism')
end
def confirmations
@@ -993,9 +1027,13 @@
private
def add_parents!
self.parents ||= []
+ end
+
+ def add_families!
+ self.families ||= []
end
def add_relationships!
self.relationships ||= PersonRelationships.new
end
\ No newline at end of file