Class: FruitToLime::Organization

Inherits:
Object
  • Object
show all
Includes:
ModelHasCustomFields, ModelHasTags, SerializeHelper
Defined in:
lib/fruit_to_lime/model/organization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SerializeHelper

#get_import_rows, get_import_rows, #map_symbol_to_row, #map_to_row, serialize, #serialize, #serialize_to_file, serialize_to_file, serialize_variables, #symbol_to_name

Methods included from ModelHasCustomFields

#set_custom_field

Methods included from ModelHasTags

#add_tag

Constructor Details

#initializeOrganization

Returns a new instance of Organization.



51
52
# File 'lib/fruit_to_lime/model/organization.rb', line 51

def initialize()
end

Instance Attribute Details

#central_phone_numberObject

Returns the value of attribute central_phone_number.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def central_phone_number
  @central_phone_number
end

#emailObject

Returns the value of attribute email.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def email
  @email
end

#employeesObject (readonly)

Returns the value of attribute employees.



49
50
51
# File 'lib/fruit_to_lime/model/organization.rb', line 49

def employees
  @employees
end

Returns the value of attribute external_link.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def external_link
  @external_link
end

#idObject

Returns the value of attribute id.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def id
  @id
end

#integration_idObject

Returns the value of attribute integration_id.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def integration_id
  @integration_id
end

#nameObject

Returns the value of attribute name.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def name
  @name
end

#organization_numberObject

Returns the value of attribute organization_number.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def organization_number
  @organization_number
end

#postal_addressObject

Returns the value of attribute postal_address.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def postal_address
  @postal_address
end

#responsible_coworkerObject

Returns the value of attribute responsible_coworker.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def responsible_coworker
  @responsible_coworker
end

#source_dataObject

Returns the value of attribute source_data.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def source_data
  @source_data
end

#visit_addressObject

Returns the value of attribute visit_address.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def visit_address
  @visit_address
end

#web_siteObject

Returns the value of attribute web_site.



46
47
48
# File 'lib/fruit_to_lime/model/organization.rb', line 46

def web_site
  @web_site
end

Instance Method Details

#==(that) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fruit_to_lime/model/organization.rb', line 62

def ==(that)
    if that.nil?
        return false
    end

    if that.is_a? Organization
        return @integration_id == that.integration_id
    elsif that.is_a? String
        return @integration_id == that
    end

    return false
end

#add_employee(val) ⇒ Object



91
92
93
94
# File 'lib/fruit_to_lime/model/organization.rb', line 91

def add_employee(val)
    @employees = [] if @employees==nil
    @employees.push(if val.is_a? Person then val else Person.new(val) end)
end

#serialize_nameObject



113
114
115
# File 'lib/fruit_to_lime/model/organization.rb', line 113

def serialize_name
    "Organization"
end

#serialize_variablesObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fruit_to_lime/model/organization.rb', line 96

def serialize_variables
    [
     :id, :integration_id, :name, :organization_number, :external_link,
     :email, :web_site, :central_phone_number ].map {
        |prop| { :id => prop, :type => :string }
    } +
        [
         { :id => :postal_address, :type => :address },
         { :id => :visit_address, :type => :address },
         { :id => :employees, :type => :persons },
         { :id => :tags, :type => :tags },
         { :id => :custom_fields, :type => :custom_fields },
         { :id => :source, :type => :source_ref },
         { :id => :responsible_coworker, :type => :coworker_reference}
        ]
end

#to_referenceObject



54
55
56
57
58
59
60
# File 'lib/fruit_to_lime/model/organization.rb', line 54

def to_reference()
    reference = OrganizationReference.new
    reference.id = @id
    reference.integration_id = @integration_id
    reference.heading = @name
    return reference
end

#to_sObject



117
118
119
# File 'lib/fruit_to_lime/model/organization.rb', line 117

def to_s
    return "#{name}"
end

#validateObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/fruit_to_lime/model/organization.rb', line 121

def validate
    error = String.new

    if @name.nil? || @name.empty?
        error = "A name is required for organization.\n#{serialize()}"
    end

    if @employees != nil
        @employees.each do |person|
            validation_message = person.validate()
            if !validation_message.empty?
                error = "#{error}\n#{validation_message}"
            end
        end
    end

    return error
end

#with_postal_address {|@postal_address| ... } ⇒ Object

Yields:



76
77
78
79
# File 'lib/fruit_to_lime/model/organization.rb', line 76

def with_postal_address
    @postal_address = Address.new
    yield @postal_address
end

#with_source {|@source| ... } ⇒ Object

Yields:

  • (@source)


86
87
88
89
# File 'lib/fruit_to_lime/model/organization.rb', line 86

def with_source
    @source = ReferenceToSource.new
    yield @source
end

#with_visit_address {|@visit_address| ... } ⇒ Object

Yields:



81
82
83
84
# File 'lib/fruit_to_lime/model/organization.rb', line 81

def with_visit_address
    @visit_address = Address.new
    yield @visit_address
end