Class: ShelbyArena::Family
Instance Attribute Summary
Attributes inherited from ApiObject
#error_messages, #marked_for_destruction
Class Method Summary collapse
-
.load_by_id(family_id) ⇒ Object
Loads the family by the specified ID.
Instance Method Summary collapse
-
#initialize(reader = nil, options = {}) ⇒ Family
constructor
Constructor.
Methods inherited from ApiObject
Constructor Details
#initialize(reader = nil, options = {}) ⇒ Family
Constructor.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/api/family.rb', line 27 def initialize(reader = nil, = {}) #@writer_object = FamilyWriter if reader.is_a?(FamilyReader) initialize_from_json_object(reader.load_data['Family']) elsif reader.is_a?(Hash) initialize_from_json_object(reader) else # new empty raise 'Not sure about this one yet' # reader = FamilyReader.new # initialize_from_json_object(reader.load_new['family']) end # The data loaded from family_members is useless. It is best to just reload all the family # members as person objects so all attributes are set. # fm[0] is 'Person' # fm[1] is a Hash of person info to match some, not all, of the attributes above. method_to_call = "#{ShelbyArena::attr_underscore('family_members')}=" self.send(method_to_call, self.family_members.collect { |fm| ShelbyArena::Person.load_by_id(fm[1]['PersonID']) }) end |
Class Method Details
.load_by_id(family_id) ⇒ Object
Loads the family by the specified ID.
Returns a new Family object.
15 16 17 18 19 20 |
# File 'lib/api/family.rb', line 15 def self.load_by_id(family_id) reader = FamilyReader.new(family_id) self.new(reader) rescue nil end |