Module: Iqvoc::CompoundForms::LabelExtensions

Extended by:
ActiveSupport::Concern
Defined in:
lib/iqvoc/compound_forms/label_extensions.rb

Instance Method Summary collapse

Instance Method Details

#compound_form_contents_sizeObject



65
66
67
68
69
70
71
72
73
# File 'lib/iqvoc/compound_forms/label_extensions.rb', line 65

def compound_form_contents_size
  if validatable_for_publishing?
    compound_forms.each do |cf|
      if cf.compound_form_contents.count < 2
        errors.add :base, I18n.t("txt.models.label.compound_form_contents_error")
      end
    end
  end
end

#compound_inObject



44
45
46
47
48
# File 'lib/iqvoc/compound_forms/label_extensions.rb', line 44

def compound_in
  CompoundForm::Base.joins(:compound_form_contents).
      where(:compound_form_contents => { :label_id => id }).
      includes(:domain).map(&:domain)
end

#inline_compound_form_originsObject

Serialized setters and getters (rn or , separated)



51
52
53
# File 'lib/iqvoc/compound_forms/label_extensions.rb', line 51

def inline_compound_form_origins
  @inline_compound_form_origins || []
end

#inline_compound_form_origins=(value_collection) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/iqvoc/compound_forms/label_extensions.rb', line 55

def inline_compound_form_origins=(value_collection)
  # write to instance variable and write it on after_safe
  @inline_compound_form_origins ||= []

  value_collection.reject(&:blank?).each do |value|
    @inline_compound_form_origins << value.split(/\r\n|, */).map(&:strip). # XXX: use Iqvoc::InlineDataHelper?
        reject(&:blank?).uniq
  end
end