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.
67 68 69 70 71 72 73 74 |
# File 'lib/fruit_to_lime/model/deal.rb', line 67 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
42 43 44 |
# File 'lib/fruit_to_lime/model/deal.rb', line 42 def custom_values @custom_values end |
#customer ⇒ Object
Returns the value of attribute customer.
44 45 46 |
# File 'lib/fruit_to_lime/model/deal.rb', line 44 def customer @customer end |
#customer_contact ⇒ Object
Returns the value of attribute customer_contact.
44 45 46 |
# File 'lib/fruit_to_lime/model/deal.rb', line 44 def customer_contact @customer_contact end |
#description ⇒ Object
Returns the value of attribute description.
39 40 41 |
# File 'lib/fruit_to_lime/model/deal.rb', line 39 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
39 40 41 |
# File 'lib/fruit_to_lime/model/deal.rb', line 39 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
39 40 41 |
# File 'lib/fruit_to_lime/model/deal.rb', line 39 def integration_id @integration_id end |
#name ⇒ Object
Returns the value of attribute name.
39 40 41 |
# File 'lib/fruit_to_lime/model/deal.rb', line 39 def name @name end |
#order_date ⇒ Object
Returns the value of attribute order_date.
39 40 41 |
# File 'lib/fruit_to_lime/model/deal.rb', line 39 def order_date @order_date end |
#probability ⇒ Object
Returns the value of attribute probability.
39 40 41 |
# File 'lib/fruit_to_lime/model/deal.rb', line 39 def probability @probability end |
#responsible_coworker ⇒ Object
Returns the value of attribute responsible_coworker.
44 45 46 |
# File 'lib/fruit_to_lime/model/deal.rb', line 44 def responsible_coworker @responsible_coworker end |
#status ⇒ Object
Get/set the deal’s status. Statuses must be configured in LIME Go before the import.
37 38 39 |
# File 'lib/fruit_to_lime/model/deal.rb', line 37 def status @status end |
#value ⇒ Object
Returns the value of attribute value.
44 45 46 |
# File 'lib/fruit_to_lime/model/deal.rb', line 44 def value @value end |
Instance Method Details
#is_float?(value) ⇒ Boolean
141 142 143 |
# File 'lib/fruit_to_lime/model/deal.rb', line 141 def is_float?(value) true if Float(value) rescue false end |
#is_integer?(value) ⇒ Boolean
137 138 139 |
# File 'lib/fruit_to_lime/model/deal.rb', line 137 def is_integer?(value) true if Integer(value) rescue false end |
#serialize_name ⇒ Object
63 64 65 |
# File 'lib/fruit_to_lime/model/deal.rb', line 63 def serialize_name "Deal" end |
#serialize_variables ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fruit_to_lime/model/deal.rb', line 46 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
80 81 82 83 84 85 |
# File 'lib/fruit_to_lime/model/deal.rb', line 80 def to_reference reference = DealReference.new reference.id = @id reference.integration_id = @integration_id return reference end |
#to_s ⇒ Object
76 77 78 |
# File 'lib/fruit_to_lime/model/deal.rb', line 76 def to_s return "deal[id=#{@id}, integration_id=#{@integration_id}]" end |
#validate ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fruit_to_lime/model/deal.rb', line 87 def validate error = String.new if @name.nil? || @name.empty? error = "A name is required for deal.\n}" end if @customer.nil? error = "#{error}\nA customer is required for deal." end if error.length > 0 error = "#{error}\n#{serialize()}" end return error end |
#with_status {|@status| ... } ⇒ Object
105 106 107 108 |
# File 'lib/fruit_to_lime/model/deal.rb', line 105 def with_status @status = DealStatus.new yield @status end |