Class: MoveToGo::DealStatusReference
- Inherits:
-
Object
- Object
- MoveToGo::DealStatusReference
- Includes:
- SerializeHelper
- Defined in:
- lib/move-to-go/model/deal_status_reference.rb
Instance Attribute Summary collapse
-
#integration_id ⇒ Object
Returns the value of attribute integration_id.
-
#label ⇒ Object
Returns the value of attribute label.
Class Method Summary collapse
-
.from_deal_status(deal_status) ⇒ Object
Converts the specifed status to a status reference.
Instance Method Summary collapse
-
#initialize(opt = nil) ⇒ DealStatusReference
constructor
A new instance of DealStatusReference.
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #validate ⇒ Object
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Constructor Details
#initialize(opt = nil) ⇒ DealStatusReference
Returns a new instance of DealStatusReference.
7 8 9 10 11 12 13 14 |
# File 'lib/move-to-go/model/deal_status_reference.rb', line 7 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
#integration_id ⇒ Object
Returns the value of attribute integration_id.
5 6 7 |
# File 'lib/move-to-go/model/deal_status_reference.rb', line 5 def integration_id @integration_id end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/move-to-go/model/deal_status_reference.rb', line 5 def label @label end |
Class Method Details
.from_deal_status(deal_status) ⇒ Object
Converts the specifed status to a status reference.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/move-to-go/model/deal_status_reference.rb', line 25 def self.from_deal_status(deal_status) if deal_status.nil? return nil elsif deal_status.is_a?(DealStatusSetting) return deal_status.to_reference elsif deal_status.is_a?(String) return DealStatusReference.new({:label => deal_status, :integration_id => deal_status}) end raise InvalidDealStatusError end |
Instance Method Details
#serialize_name ⇒ Object
20 21 22 |
# File 'lib/move-to-go/model/deal_status_reference.rb', line 20 def serialize_name "StatusReference" end |
#serialize_variables ⇒ Object
16 17 18 |
# File 'lib/move-to-go/model/deal_status_reference.rb', line 16 def serialize_variables [:integration_id, :label].map {|p| {:id => p, :type => :string} } end |
#validate ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/move-to-go/model/deal_status_reference.rb', line 37 def validate error = "" if (@label.nil? || @label.empty?) && (@integration_id.nil? || @integration_id.empty?) error = "label and integration_id can't all be nil or empty" end return error end |