2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-08-08 18:48:11 -04:00
|
|
|
class Contract < ActiveRecord::Base
|
|
|
|
belongs_to :company
|
2017-12-31 15:20:00 -05:00
|
|
|
belongs_to :developer, primary_key: :id
|
2016-08-06 13:37:57 -04:00
|
|
|
belongs_to :firm, foreign_key: "company_id"
|
2011-05-31 06:08:11 -04:00
|
|
|
|
2019-02-12 12:06:06 -05:00
|
|
|
attribute :metadata, :json
|
|
|
|
|
|
|
|
before_save :hi, :update_metadata
|
2011-05-31 06:08:11 -04:00
|
|
|
after_save :bye
|
|
|
|
|
|
|
|
attr_accessor :hi_count, :bye_count
|
|
|
|
|
|
|
|
def hi
|
|
|
|
@hi_count ||= 0
|
|
|
|
@hi_count += 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def bye
|
|
|
|
@bye_count ||= 0
|
|
|
|
@bye_count += 1
|
|
|
|
end
|
2019-02-12 12:06:06 -05:00
|
|
|
|
|
|
|
def update_metadata
|
|
|
|
self.metadata = { company_id: company_id, developer_id: developer_id }
|
|
|
|
end
|
2010-12-12 11:35:27 -05:00
|
|
|
end
|
2018-08-21 11:23:17 -04:00
|
|
|
|
|
|
|
class NewContract < Contract
|
|
|
|
validates :company_id, presence: true
|
|
|
|
end
|