Class: MoveToGo::Meeting

Inherits:
CanBecomeImmutable show all
Includes:
SerializeHelper
Defined in:
lib/move-to-go/model/meeting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SerializeHelper

#serialize, #serialize_to_file

Methods inherited from CanBecomeImmutable

immutable_accessor, #is_immutable, #raise_if_immutable, #set_is_immutable

Constructor Details

#initialize(opt = nil) ⇒ Meeting

Returns a new instance of Meeting.



15
16
17
18
19
20
21
22
# File 'lib/move-to-go/model/meeting.rb', line 15

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

#assigned_coworkerObject

Returns the value of attribute assigned_coworker.



13
14
15
# File 'lib/move-to-go/model/meeting.rb', line 13

def assigned_coworker
  @assigned_coworker
end

#created_byObject

Returns the value of attribute created_by.



13
14
15
# File 'lib/move-to-go/model/meeting.rb', line 13

def created_by
  @created_by
end

#date_startObject

Returns the value of attribute date_start.



12
13
14
# File 'lib/move-to-go/model/meeting.rb', line 12

def date_start
  @date_start
end

#date_start_has_timeObject

Returns the value of attribute date_start_has_time.



12
13
14
# File 'lib/move-to-go/model/meeting.rb', line 12

def date_start_has_time
  @date_start_has_time
end

#date_stopObject

Returns the value of attribute date_stop.



11
12
13
# File 'lib/move-to-go/model/meeting.rb', line 11

def date_stop
  @date_stop
end

#datecheckedObject

Returns the value of attribute datechecked.



12
13
14
# File 'lib/move-to-go/model/meeting.rb', line 12

def datechecked
  @datechecked
end

#dealObject

Returns the value of attribute deal.



13
14
15
# File 'lib/move-to-go/model/meeting.rb', line 13

def deal
  @deal
end

#headingObject

Returns the value of attribute heading.



11
12
13
# File 'lib/move-to-go/model/meeting.rb', line 11

def heading
  @heading
end

#locationObject

Returns the value of attribute location.



11
12
13
# File 'lib/move-to-go/model/meeting.rb', line 11

def location
  @location
end

#organizationObject

Returns the value of attribute organization.



13
14
15
# File 'lib/move-to-go/model/meeting.rb', line 13

def organization
  @organization
end

#personObject

Returns the value of attribute person.



13
14
15
# File 'lib/move-to-go/model/meeting.rb', line 13

def person
  @person
end

#textObject

Returns the value of attribute text.



11
12
13
# File 'lib/move-to-go/model/meeting.rb', line 11

def text
  @text
end

Instance Method Details

#get_import_rowsObject



43
44
45
46
47
48
49
50
# File 'lib/move-to-go/model/meeting.rb', line 43

def get_import_rows
    (serialize_variables + [
        { :id => :organization, :type => :organization_reference},
        { :id => :person, :type => :person_reference}
        ]).map do |p|
        map_to_row p
    end
end

#idObject

:attr_accessor: id



6
# File 'lib/move-to-go/model/meeting.rb', line 6

immutable_accessor :id

#integration_idObject

:attr_accessor: integration_id



9
# File 'lib/move-to-go/model/meeting.rb', line 9

immutable_accessor :integration_id

#serialize_nameObject



52
53
54
# File 'lib/move-to-go/model/meeting.rb', line 52

def serialize_name
    "Meeting"
end

#serialize_variablesObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/move-to-go/model/meeting.rb', line 24

def serialize_variables
    [ :id, :text, :heading, :location, :integration_id ].map {
        |p| {
            :id => p,
            :type => :string
        }
    } +
        [
         { :id => :date_start, :type => :datetime },
         { :id => :date_stop, :type => :datetime },
         { :id => :date_start_has_time, :type => :bool },
         { :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
         { :id => :assigned_coworker_reference, :type => :coworker_reference, :element_name => :assigned_coworker },
         { :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
         { :id => :deal_reference, :type => :deal_reference, :element_name => :deal },
         { :id => :person_reference, :type => :person_reference, :element_name => :person }
        ]
end

#validateObject



189
190
191
192
193
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/move-to-go/model/meeting.rb', line 189

def validate
    error = String.new

    if (@heading.nil? || @heading.empty?)
        error = "Heading is required for meeting\n"
    end

    if @created_by.nil?
        error = "#{error}Created_by is required for meeting\n"
    end

    if @date_start.nil?
        error = "#{error}Date_start is required for meeting\n"
    end

    if @date_start_has_time.nil?
        error = "#{error}Date_start_has_time is required for meeting\n"
    end

    if @date_stop.nil?
        error = "#{error}Date_stop is required for meeting\n"
    end

    if @organization.nil?
        error = "#{error}Organization is required for meeting\n"
    end

    return error
end