Class: FruitToLime::Organization
- Inherits:
-
Object
- Object
- FruitToLime::Organization
- Includes:
- ModelHasCustomFields, ModelHasTags, SerializeHelper
- Defined in:
- lib/fruit_to_lime/model/organization.rb
Instance Attribute Summary collapse
-
#central_phone_number ⇒ Object
Returns the value of attribute central_phone_number.
-
#custom_values ⇒ Object
readonly
you add custom values by using ModelHasCustomFields#set_custom_value.
-
#email ⇒ Object
Returns the value of attribute email.
-
#employees ⇒ Object
readonly
Returns the value of attribute employees.
-
#id ⇒ Object
Returns the value of attribute id.
-
#integration_id ⇒ Object
Returns the value of attribute integration_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#organization_number ⇒ Object
Returns the value of attribute organization_number.
-
#postal_address ⇒ Object
Returns the value of attribute postal_address.
-
#relation ⇒ Object
Returns the value of attribute relation.
-
#relation_last_modified ⇒ Object
Sets/gets the date when this organization’s relation was changed.
-
#responsible_coworker ⇒ Object
Returns the value of attribute responsible_coworker.
-
#source_data ⇒ Object
Returns the value of attribute source_data.
-
#visit_address ⇒ Object
Returns the value of attribute visit_address.
-
#web_site ⇒ Object
Returns the value of attribute web_site.
Instance Method Summary collapse
- #==(that) ⇒ Object
- #add_employee(val) ⇒ Object
- #find_employee_by_integration_id(integration_id) ⇒ Object
-
#initialize(opt = nil) ⇒ Organization
constructor
A new instance of Organization.
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #to_reference ⇒ Object
- #to_s ⇒ Object
- #validate ⇒ Object
- #with_postal_address {|@postal_address| ... } ⇒ Object
- #with_source {|@source| ... } ⇒ Object
- #with_visit_address {|@visit_address| ... } ⇒ Object
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Methods included from ModelHasCustomFields
#set_custom_field, #set_custom_value
Methods included from ModelHasTags
Constructor Details
#initialize(opt = nil) ⇒ Organization
Returns a new instance of Organization.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fruit_to_lime/model/organization.rb', line 55 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 @relation = Relation::NoRelation if @relation.nil? end |
Instance Attribute Details
#central_phone_number ⇒ Object
Returns the value of attribute central_phone_number.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def central_phone_number @central_phone_number end |
#custom_values ⇒ Object (readonly)
you add custom values by using ModelHasCustomFields#set_custom_value
53 54 55 |
# File 'lib/fruit_to_lime/model/organization.rb', line 53 def custom_values @custom_values end |
#email ⇒ Object
Returns the value of attribute email.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def email @email end |
#employees ⇒ Object (readonly)
Returns the value of attribute employees.
51 52 53 |
# File 'lib/fruit_to_lime/model/organization.rb', line 51 def employees @employees end |
#id ⇒ Object
Returns the value of attribute id.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def integration_id @integration_id end |
#name ⇒ Object
Returns the value of attribute name.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def name @name end |
#organization_number ⇒ Object
Returns the value of attribute organization_number.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def organization_number @organization_number end |
#postal_address ⇒ Object
Returns the value of attribute postal_address.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def postal_address @postal_address end |
#relation ⇒ Object
Returns the value of attribute relation.
51 52 53 |
# File 'lib/fruit_to_lime/model/organization.rb', line 51 def relation @relation end |
#relation_last_modified ⇒ Object
Sets/gets the date when this organization’s relation was changed. Default is Now.
49 50 51 |
# File 'lib/fruit_to_lime/model/organization.rb', line 49 def relation_last_modified @relation_last_modified end |
#responsible_coworker ⇒ Object
Returns the value of attribute responsible_coworker.
51 52 53 |
# File 'lib/fruit_to_lime/model/organization.rb', line 51 def responsible_coworker @responsible_coworker end |
#source_data ⇒ Object
Returns the value of attribute source_data.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def source_data @source_data end |
#visit_address ⇒ Object
Returns the value of attribute visit_address.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def visit_address @visit_address end |
#web_site ⇒ Object
Returns the value of attribute web_site.
44 45 46 |
# File 'lib/fruit_to_lime/model/organization.rb', line 44 def web_site @web_site end |
Instance Method Details
#==(that) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/fruit_to_lime/model/organization.rb', line 74 def ==(that) if that.nil? return false end if that.is_a? Organization return @integration_id == that.integration_id end return false end |
#add_employee(val) ⇒ Object
125 126 127 128 129 130 |
# File 'lib/fruit_to_lime/model/organization.rb', line 125 def add_employee(val) @employees = [] if @employees == nil person = if val.is_a? Person then val else Person.new(val) end @employees.push(person) person end |
#find_employee_by_integration_id(integration_id) ⇒ Object
158 159 160 161 162 163 |
# File 'lib/fruit_to_lime/model/organization.rb', line 158 def find_employee_by_integration_id(integration_id) return nil if @employees.nil? return @employees.find do |e| e.integration_id == integration_id end end |
#serialize_name ⇒ Object
186 187 188 |
# File 'lib/fruit_to_lime/model/organization.rb', line 186 def serialize_name "Organization" end |
#serialize_variables ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/fruit_to_lime/model/organization.rb', line 165 def serialize_variables [ { :id => :id, :type => :string }, { :id => :integration_id, :type => :string }, { :id => :source, :type => :source_ref }, { :id => :name, :type => :string }, { :id => :organization_number, :type => :string }, { :id => :postal_address, :type => :address }, { :id => :visit_address, :type => :address }, { :id => :central_phone_number, :type => :string }, { :id => :email, :type => :string }, { :id => :web_site, :type => :string }, { :id => :employees, :type => :persons }, { :id => :custom_values, :type => :custom_values }, { :id => :tags, :type => :tags }, { :id => :responsible_coworker, :type => :coworker_reference}, { :id => :relation, :type => :string }, { :id => :relation_last_modified, :type => :string } ] end |
#to_reference ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/fruit_to_lime/model/organization.rb', line 66 def to_reference() reference = OrganizationReference.new reference.id = @id reference.integration_id = @integration_id reference.heading = @name return reference end |
#to_s ⇒ Object
190 191 192 |
# File 'lib/fruit_to_lime/model/organization.rb', line 190 def to_s return "#{name}" end |
#validate ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/fruit_to_lime/model/organization.rb', line 194 def validate error = String.new if @name.nil? || @name.empty? error = "A name is required for organization.\n#{serialize()}" end if !@source.nil? if @source.id.nil? || @source.id == "" error = "#{error}\nReference to source must have an id" end end if @employees != nil @employees.each do |person| = person.validate() if !.empty? error = "#{error}\n#{}" end end end return error end |
#with_postal_address {|@postal_address| ... } ⇒ Object
91 92 93 94 |
# File 'lib/fruit_to_lime/model/organization.rb', line 91 def with_postal_address @postal_address = Address.new if @postal_address == nil yield @postal_address end |
#with_source {|@source| ... } ⇒ Object
111 112 113 114 |
# File 'lib/fruit_to_lime/model/organization.rb', line 111 def with_source @source = ReferenceToSource.new if @source == nil yield @source end |