Class: FruitToLime::Deal
- Inherits:
-
Object
- Object
- FruitToLime::Deal
- Includes:
- ModelHasCustomFields, ModelHasTags, SerializeHelper
- Defined in:
- lib/fruit_to_lime/model/deal.rb
Instance Attribute Summary collapse
-
#custom_values ⇒ Object
readonly
you add custom values by using ModelHasCustomFields#set_custom_value.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#customer_contact ⇒ Object
Returns the value of attribute customer_contact.
-
#description ⇒ Object
Returns the value of attribute description.
-
#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.
-
#order_date ⇒ Object
Returns the value of attribute order_date.
-
#probability ⇒ Object
Returns the value of attribute probability.
-
#responsible_coworker ⇒ Object
Returns the value of attribute responsible_coworker.
-
#status ⇒ Object
Get/set the deal’s status.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(opt = nil) ⇒ Deal
constructor
A new instance of Deal.
- #is_float?(value) ⇒ Boolean
- #is_integer?(value) ⇒ Boolean
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #to_reference ⇒ Object
- #to_s ⇒ Object
- #validate ⇒ Object
- #with_status {|@status| ... } ⇒ 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) ⇒ Deal
Returns a new instance of Deal.
73 74 75 76 77 78 79 80 |
# File 'lib/fruit_to_lime/model/deal.rb', line 73 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
#custom_values ⇒ Object (readonly)
you add custom values by using ModelHasCustomFields#set_custom_value
48 49 50 |
# File 'lib/fruit_to_lime/model/deal.rb', line 48 def custom_values @custom_values end |
#customer ⇒ Object
Returns the value of attribute customer.
50 51 52 |
# File 'lib/fruit_to_lime/model/deal.rb', line 50 def customer @customer end |
#customer_contact ⇒ Object
Returns the value of attribute customer_contact.
50 51 52 |
# File 'lib/fruit_to_lime/model/deal.rb', line 50 def customer_contact @customer_contact end |
#description ⇒ Object
Returns the value of attribute description.
45 46 47 |
# File 'lib/fruit_to_lime/model/deal.rb', line 45 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
45 46 47 |
# File 'lib/fruit_to_lime/model/deal.rb', line 45 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
45 46 47 |
# File 'lib/fruit_to_lime/model/deal.rb', line 45 def integration_id @integration_id end |
#name ⇒ Object
Returns the value of attribute name.
45 46 47 |
# File 'lib/fruit_to_lime/model/deal.rb', line 45 def name @name end |
#order_date ⇒ Object
Returns the value of attribute order_date.
45 46 47 |
# File 'lib/fruit_to_lime/model/deal.rb', line 45 def order_date @order_date end |
#probability ⇒ Object
Returns the value of attribute probability.
45 46 47 |
# File 'lib/fruit_to_lime/model/deal.rb', line 45 def probability @probability end |
#responsible_coworker ⇒ Object
Returns the value of attribute responsible_coworker.
50 51 52 |
# File 'lib/fruit_to_lime/model/deal.rb', line 50 def responsible_coworker @responsible_coworker end |
#status ⇒ Object
Get/set the deal’s status. Statuses must be configured in LIME Go before the import.
43 44 45 |
# File 'lib/fruit_to_lime/model/deal.rb', line 43 def status @status end |
#value ⇒ Object
Returns the value of attribute value.
50 51 52 |
# File 'lib/fruit_to_lime/model/deal.rb', line 50 def value @value end |
Instance Method Details
#is_float?(value) ⇒ Boolean
169 170 171 |
# File 'lib/fruit_to_lime/model/deal.rb', line 169 def is_float?(value) true if Float(value) rescue false end |
#is_integer?(value) ⇒ Boolean
165 166 167 |
# File 'lib/fruit_to_lime/model/deal.rb', line 165 def is_integer?(value) true if Integer(value) rescue false end |
#serialize_name ⇒ Object
69 70 71 |
# File 'lib/fruit_to_lime/model/deal.rb', line 69 def serialize_name "Deal" end |
#serialize_variables ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fruit_to_lime/model/deal.rb', line 52 def serialize_variables [ :id, :integration_id, :name, :description, :probability, :value, :order_date ].map { |p| { :id => p, :type => :string } } + [ { :id => :customer, :type => :organization_reference }, { :id => :responsible_coworker, :type => :coworker_reference }, { :id => :customer_contact, :type => :person_reference }, { :id => :custom_values, :type => :custom_values }, { :id => :tags, :type => :tags }, { :id => :status, :type => :deal_status } ] end |
#to_reference ⇒ Object
86 87 88 89 90 91 |
# File 'lib/fruit_to_lime/model/deal.rb', line 86 def to_reference reference = DealReference.new reference.id = @id reference.integration_id = @integration_id return reference end |
#to_s ⇒ Object
82 83 84 |
# File 'lib/fruit_to_lime/model/deal.rb', line 82 def to_s return "deal[id=#{@id}, integration_id=#{@integration_id}]" end |
#validate ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fruit_to_lime/model/deal.rb', line 93 def validate error = String.new if @name.nil? || @name.empty? error = "A name is required for deal.\n}" end if !@status.nil? && @status.status_reference.nil? error = "#{error}\nStatus must have a status reference." end if !@status.nil? && !@status.status_reference.nil? && @status.status_reference.validate.length > 0 error = "#{error}\n#{@status.status_reference.validate}" end if error.length > 0 error = "#{error}\n#{serialize()}" end return error end |
#with_status {|@status| ... } ⇒ Object
116 117 118 119 |
# File 'lib/fruit_to_lime/model/deal.rb', line 116 def with_status @status = DealStatus.new if @status.nil? yield @status end |