Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
module Exploitable
extend ActiveSupport::Concern
FIELDS = [:applicable_medium, :territory, :term, :restriction]
included do
FIELDS.each do |field|
belongs_to field, optional: true
define_method "#{field}_value" do
if respond_to?(:contract_template) && contract_template.present?
# If contract template is present, use the value from there
contract_template.public_send("#{field}_value")
else
# Otherwise use the value of the label or the text
field_assoc = public_send(field)
if field_assoc
field_assoc.other? ? public_send("#{field}_text") : field_assoc.label
end
end
end
end
end
end