Class: TheCity::Family

Inherits:
ApiObject show all
Defined in:
lib/api/family.rb

Instance Attribute Summary

Attributes inherited from ApiObject

#error_messages, #marked_for_destruction

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiObject

__tc_attributes, #delete, #initialize_from_json_object, #is_deleted?, #save, #set_attributes, tc_attr_accessor, #to_attributes

Constructor Details

#initialize(json_data = nil) ⇒ Family

Constructor.

Parameters:

  • json_data (optional) (defaults to: nil)

    JSON data of the Family.



26
27
28
29
30
# File 'lib/api/family.rb', line 26

def initialize(json_data = nil)
  @family_members = []
  @writer_object = FamilyWriter
  initialize_from_json_object(json_data) unless json_data.nil?
end

Class Method Details

.load_by_id(family_id) ⇒ Object

Loads the family by the specified ID.

Returns a new TheCity::Family object.

Parameters:

  • family_id

    The ID of the family to load.



16
17
18
19
20
21
# File 'lib/api/family.rb', line 16

def self.load_by_id(family_id)
  reader = FamilyReader.new({:id => family_id})
  self.new(reader.load_feed)
rescue
  nil
end

Instance Method Details

#add_family_member(member) ⇒ Object



39
40
41
# File 'lib/api/family.rb', line 39

def add_family_member(member)
  @family_members << member
end

#membersObject

Alias family_members



34
35
36
# File 'lib/api/family.rb', line 34

def members
  @family_members
end