Class: FruitToLime::Person
- Inherits:
-
PersonReference
- Object
- PersonReference
- FruitToLime::Person
- Includes:
- SerializeHelper
- Defined in:
- lib/fruit_to_lime/model/person.rb
Instance Attribute Summary collapse
-
#alternative_email ⇒ Object
Returns the value of attribute alternative_email.
-
#currently_employed ⇒ Object
Returns the value of attribute currently_employed.
-
#custom_fields ⇒ Object
readonly
Returns the value of attribute custom_fields.
-
#direct_phone_number ⇒ Object
Returns the value of attribute direct_phone_number.
-
#email ⇒ Object
Returns the value of attribute email.
-
#fax_phone_number ⇒ Object
Returns the value of attribute fax_phone_number.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#home_phone_number ⇒ Object
Returns the value of attribute home_phone_number.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#mobile_phone_number ⇒ Object
Returns the value of attribute mobile_phone_number.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#position ⇒ Object
Returns the value of attribute position.
-
#postal_address ⇒ Object
Returns the value of attribute postal_address.
Attributes inherited from PersonReference
Instance Method Summary collapse
- #add_tag(str) ⇒ Object
- #get_import_rows ⇒ Object
-
#initialize(opt = nil) ⇒ Person
constructor
A new instance of Person.
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #set_custom_field(obj) ⇒ Object
- #tags ⇒ Object
- #to_s ⇒ Object
- #validate ⇒ Object
- #with_postal_address {|@postal_address| ... } ⇒ Object
- #with_source {|@source| ... } ⇒ Object
Methods included from SerializeHelper
get_import_rows, #map_symbol_to_row, #map_to_row, serialize, #serialize, #serialize_to_file, serialize_to_file, serialize_variables, #symbol_to_name
Methods inherited from PersonReference
#empty?, #initalize, #same_as_this_method
Constructor Details
#initialize(opt = nil) ⇒ Person
Returns a new instance of Person.
40 41 42 43 44 45 46 47 |
# File 'lib/fruit_to_lime/model/person.rb', line 40 def initialize(opt = nil) if opt != nil serialize_variables.each do |myattr| val = opt[myattr[:id]] instance_variable_set("@" + myattr[:id].to_s, val) if val != nil end end end |
Instance Attribute Details
#alternative_email ⇒ Object
Returns the value of attribute alternative_email.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def alternative_email @alternative_email end |
#currently_employed ⇒ Object
Returns the value of attribute currently_employed.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def currently_employed @currently_employed end |
#custom_fields ⇒ Object (readonly)
Returns the value of attribute custom_fields.
38 39 40 |
# File 'lib/fruit_to_lime/model/person.rb', line 38 def custom_fields @custom_fields end |
#direct_phone_number ⇒ Object
Returns the value of attribute direct_phone_number.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def direct_phone_number @direct_phone_number end |
#email ⇒ Object
Returns the value of attribute email.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def email @email end |
#fax_phone_number ⇒ Object
Returns the value of attribute fax_phone_number.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def fax_phone_number @fax_phone_number end |
#first_name ⇒ Object
Returns the value of attribute first_name.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def first_name @first_name end |
#home_phone_number ⇒ Object
Returns the value of attribute home_phone_number.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def home_phone_number @home_phone_number end |
#last_name ⇒ Object
Returns the value of attribute last_name.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def last_name @last_name end |
#mobile_phone_number ⇒ Object
Returns the value of attribute mobile_phone_number.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def mobile_phone_number @mobile_phone_number end |
#organization ⇒ Object
Returns the value of attribute organization.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def organization @organization end |
#position ⇒ Object
Returns the value of attribute position.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def position @position end |
#postal_address ⇒ Object
Returns the value of attribute postal_address.
34 35 36 |
# File 'lib/fruit_to_lime/model/person.rb', line 34 def postal_address @postal_address end |
Instance Method Details
#add_tag(str) ⇒ Object
68 69 70 71 |
# File 'lib/fruit_to_lime/model/person.rb', line 68 def add_tag(str) @tags = [] if @tags == nil @tags.push(Tag.new(str)) end |
#get_import_rows ⇒ Object
94 95 96 97 98 |
# File 'lib/fruit_to_lime/model/person.rb', line 94 def get_import_rows (serialize_variables + [ { :id => :organization, :type => :organization_reference } ]).map do |p| map_to_row p end end |
#serialize_name ⇒ Object
73 74 75 |
# File 'lib/fruit_to_lime/model/person.rb', line 73 def serialize_name "Person" end |
#serialize_variables ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/fruit_to_lime/model/person.rb', line 77 def serialize_variables [ :id, :integration_id, :first_name, :last_name, :direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number, :position, :email, :alternative_email ].map { |prop| {:id => prop, :type => :string} }+[ {:id => :postal_address, :type => :address}, {:id => :currently_employed, :type => :bool}, {:id => :tags, :type => :tags}, {:id => :custom_fields, :type => :custom_fields}, {:id => :source, :type => :source_ref}, {:id => :organization, :type => :organization_reference} ] end |
#set_custom_field(obj) ⇒ Object
54 55 56 57 |
# File 'lib/fruit_to_lime/model/person.rb', line 54 def set_custom_field(obj) @custom_fields = [] if @custom_fields==nil @custom_fields.push CustomField.new(obj) end |
#tags ⇒ Object
64 65 66 |
# File 'lib/fruit_to_lime/model/person.rb', line 64 def @tags end |
#to_s ⇒ Object
100 101 102 |
# File 'lib/fruit_to_lime/model/person.rb', line 100 def to_s return "#{first_name} #{last_name}" end |
#validate ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fruit_to_lime/model/person.rb', line 104 def validate error = String.new if (@first_name.nil? || @first_name.empty?) && (@last_name.nil? || @last_name.empty?) error = "A firstname or lastname is required for person.\n#{serialize()}" end return error end |
#with_postal_address {|@postal_address| ... } ⇒ Object
49 50 51 52 |
# File 'lib/fruit_to_lime/model/person.rb', line 49 def with_postal_address @postal_address = Address.new yield @postal_address end |
#with_source {|@source| ... } ⇒ Object
59 60 61 62 |
# File 'lib/fruit_to_lime/model/person.rb', line 59 def with_source @source = ReferenceToSource.new yield @source end |