Class: ShelbyArena::Person

Inherits:
ApiObject show all
Defined in:
lib/api/person.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

#initialize_from_json_object

Constructor Details

#initialize(reader = nil, options = {}) ⇒ Person

Constructor.

Parameters:

  • reader (optional) (defaults to: nil)

    The object that has the data. This can be a PersonReader or Hash object.

  • options (optional) (defaults to: {})

    Options for including more information.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/api/person.rb', line 46

def initialize(reader = nil, options = {})       
  @writer_object = PersonWriter
  if reader.is_a?(PersonReader)
    initialize_from_json_object(reader.load_data['Person'])
  elsif reader.is_a?(Hash) 
    initialize_from_json_object(reader)        
  else # new empty
    raise 'Not sure about this one yet'
    # reader = PersonReader.new
    # initialize_from_json_object(reader.load_new['person'])
  end         
end

Class Method Details

.load_by_id(person_id) ⇒ Object

Loads the user by the specified ID.

Returns a new Person object.

Parameters:

  • person_id

    The ID of the person to load.



34
35
36
37
38
39
# File 'lib/api/person.rb', line 34

def self.load_by_id(person_id)
  reader = PersonReader.new(person_id)
  self.new(reader)
rescue
  nil      
end

Instance Method Details

#email_addressObject



74
75
76
# File 'lib/api/person.rb', line 74

def email_address
  self.first_active_email
end

#family_roleObject



65
66
67
# File 'lib/api/person.rb', line 65

def family_role
  self.family_member_role_value.blank? ? 'Other' : self.family_member_role_value
end

#is_child?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/api/person.rb', line 70

def is_child?
  self.family_member_role_value.downcase == 'child'
end