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.
-
#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.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fruit_to_lime/model/organization.rb', line 50 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.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def central_phone_number @central_phone_number end |
#custom_values ⇒ Object (readonly)
you add custom values by using ModelHasCustomFields#set_custom_value
48 49 50 |
# File 'lib/fruit_to_lime/model/organization.rb', line 48 def custom_values @custom_values end |
#email ⇒ Object
Returns the value of attribute email.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def email @email end |
#employees ⇒ Object (readonly)
Returns the value of attribute employees.
46 47 48 |
# File 'lib/fruit_to_lime/model/organization.rb', line 46 def employees @employees end |
#id ⇒ Object
Returns the value of attribute id.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def integration_id @integration_id end |
#name ⇒ Object
Returns the value of attribute name.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def name @name end |
#organization_number ⇒ Object
Returns the value of attribute organization_number.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def organization_number @organization_number end |
#postal_address ⇒ Object
Returns the value of attribute postal_address.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def postal_address @postal_address end |
#relation ⇒ Object
Returns the value of attribute relation.
46 47 48 |
# File 'lib/fruit_to_lime/model/organization.rb', line 46 def relation @relation end |
#responsible_coworker ⇒ Object
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_data ⇒ Object
Returns the value of attribute source_data.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def source_data @source_data end |
#visit_address ⇒ Object
Returns the value of attribute visit_address.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def visit_address @visit_address end |
#web_site ⇒ Object
Returns the value of attribute web_site.
43 44 45 |
# File 'lib/fruit_to_lime/model/organization.rb', line 43 def web_site @web_site end |
Instance Method Details
#==(that) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fruit_to_lime/model/organization.rb', line 69 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
120 121 122 123 124 125 |
# File 'lib/fruit_to_lime/model/organization.rb', line 120 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
143 144 145 146 147 148 |
# File 'lib/fruit_to_lime/model/organization.rb', line 143 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
170 171 172 |
# File 'lib/fruit_to_lime/model/organization.rb', line 170 def serialize_name "Organization" end |
#serialize_variables ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/fruit_to_lime/model/organization.rb', line 150 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 } ] end |
#to_reference ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/fruit_to_lime/model/organization.rb', line 61 def to_reference() reference = OrganizationReference.new reference.id = @id reference.integration_id = @integration_id reference.heading = @name return reference end |
#to_s ⇒ Object
174 175 176 |
# File 'lib/fruit_to_lime/model/organization.rb', line 174 def to_s return "#{name}" end |
#validate ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/fruit_to_lime/model/organization.rb', line 178 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| = person.validate() if !.empty? error = "#{error}\n#{}" end end end return error end |
#with_postal_address {|@postal_address| ... } ⇒ Object
86 87 88 89 |
# File 'lib/fruit_to_lime/model/organization.rb', line 86 def with_postal_address @postal_address = Address.new if @postal_address == nil yield @postal_address end |
#with_source {|@source| ... } ⇒ Object
106 107 108 109 |
# File 'lib/fruit_to_lime/model/organization.rb', line 106 def with_source @source = ReferenceToSource.new if @source == nil yield @source end |