Class: MoveToGo::DealReference
- Inherits:
-
Object
- Object
- MoveToGo::DealReference
- Includes:
- SerializeHelper
- Defined in:
- lib/move-to-go/model/deal.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#integration_id ⇒ Object
Returns the value of attribute integration_id.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(opt = nil) ⇒ DealReference
constructor
A new instance of DealReference.
- #serialize_variables ⇒ Object
- #to_s ⇒ Object
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Constructor Details
#initialize(opt = nil) ⇒ DealReference
Returns a new instance of DealReference.
9 10 11 12 13 14 15 16 |
# File 'lib/move-to-go/model/deal.rb', line 9 def initialize(opt = nil) if opt != nil serialize_variables.each do |var| value = opt[var[:id]] instance_variable_set("@" + var[:id].to_s, value) if value != nil end end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/move-to-go/model/deal.rb', line 4 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
4 5 6 |
# File 'lib/move-to-go/model/deal.rb', line 4 def integration_id @integration_id end |
Class Method Details
.from_deal(deal) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/move-to-go/model/deal.rb', line 26 def self.from_deal(deal) if deal.nil? return nil elsif deal.is_a?(Deal) return deal.to_reference elsif deal.is_a?(DealReference) return deal end end |
Instance Method Details
#empty? ⇒ Boolean
22 23 24 |
# File 'lib/move-to-go/model/deal.rb', line 22 def empty? return !@integration_id && !@id end |
#serialize_variables ⇒ Object
5 6 7 |
# File 'lib/move-to-go/model/deal.rb', line 5 def serialize_variables [ :id, :integration_id ].map { |prop| {:id => prop, :type => :string} } end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/move-to-go/model/deal.rb', line 18 def to_s return "(#{id}, #{integration_id})" end |