Class: MoveToGo::DealClassSettings
- Inherits:
-
ClassSettings
- Object
- ClassSettings
- MoveToGo::DealClassSettings
- Defined in:
- lib/move-to-go/model/deal_class_settings.rb
Instance Attribute Summary collapse
-
#default_status ⇒ Object
Returns the value of attribute default_status.
-
#statuses ⇒ Object
readonly
Returns the value of attribute statuses.
Attributes inherited from ClassSettings
Instance Method Summary collapse
- #add_status(obj) ⇒ Object
- #find_status_by_id(id) ⇒ Object
- #find_status_by_integration_id(integration_id) ⇒ Object
- #find_status_by_label(label) ⇒ Object
-
#initialize(opt = nil) ⇒ DealClassSettings
constructor
A new instance of DealClassSettings.
- #serialize_variables ⇒ Object
Methods inherited from ClassSettings
#serialize_name, #set_custom_field
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Constructor Details
#initialize(opt = nil) ⇒ DealClassSettings
Returns a new instance of DealClassSettings.
12 13 14 15 16 17 18 19 20 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 12 def initialize(opt = nil) @statuses = [] 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
#default_status ⇒ Object
Returns the value of attribute default_status.
8 9 10 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 8 def default_status @default_status end |
#statuses ⇒ Object (readonly)
Returns the value of attribute statuses.
6 7 8 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 6 def statuses @statuses end |
Instance Method Details
#add_status(obj) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 28 def add_status(obj) @statuses = [] if @statuses.nil? if obj.is_a?(DealStatusSetting) status = obj else status = DealStatusSetting.new(obj) end if status.label.nil? || status.label.empty? raise InvalidDealStatusError, "Deal status must have a label" end if status.assessment.nil? status.assessment = DealState::NotAnEndState end index = @statuses.find_index do |deal_status| deal_status.same_as?(status) end if index @statuses.delete_at index end @statuses.push status return status end |
#find_status_by_id(id) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 89 def find_status_by_id(id) return nil if @statuses.nil? return @statuses.find do |status| !status.id.nil? && status.id.casecmp(integration_id) == 0 end end |
#find_status_by_integration_id(integration_id) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 81 def find_status_by_integration_id(integration_id) return nil if @statuses.nil? || integration_id.nil? return @statuses.find do |status| !status.integration_id.nil? && status.integration_id.casecmp(integration_id) == 0 end end |
#find_status_by_label(label) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 73 def find_status_by_label(label) return nil if @statuses.nil? || label.nil? return @statuses.find do |status| !status.label.nil? && status.label.casecmp(label) == 0 end end |
#serialize_variables ⇒ Object
22 23 24 25 26 |
# File 'lib/move-to-go/model/deal_class_settings.rb', line 22 def serialize_variables super() + [{:id => :statuses, :type => :statuses }, {:id => :default_status, :type => :deal_status_reference} ] end |