Module: CompoundFormsLabelExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/compound_forms_label_extensions.rb
Instance Method Summary collapse
- #compound_form_contents_languages ⇒ Object
- #compound_form_contents_self_reference ⇒ Object
- #compound_form_contents_size ⇒ Object
- #compound_in ⇒ Object
-
#inline_compound_form_origins ⇒ Object
Serialized setters and getters (rn or , separated).
- #inline_compound_form_origins=(value_collection) ⇒ Object
Instance Method Details
#compound_form_contents_languages ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'app/models/concerns/compound_forms_label_extensions.rb', line 78 def compound_form_contents_languages if validatable_for_publishing? compound_form_contents.each do |cfc| if cfc.label.language != language errors.add :base, I18n.t("txt.models.label.compound_form_contents_language_error") break end end end end |
#compound_form_contents_self_reference ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'app/models/concerns/compound_forms_label_extensions.rb', line 89 def compound_form_contents_self_reference if validatable_for_publishing? cfc_label_ids = compound_form_contents.map {|cfc| cfc.label_id } if cfc_label_ids.include? published_version_id errors.add :base, I18n.t("txt.models.label.compound_form_contents_self_reference_error") end end end |
#compound_form_contents_size ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'app/models/concerns/compound_forms_label_extensions.rb', line 68 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_size_error") end end end end |
#compound_in ⇒ Object
46 47 48 49 50 51 |
# File 'app/models/concerns/compound_forms_label_extensions.rb', line 46 def compound_in # FIXME: sort with database function CompoundForm::Base.joins(:compound_form_contents) .where(:compound_form_contents => { :label_id => id }) .includes(:domain).map(&:domain).sort_by(&:value) end |
#inline_compound_form_origins ⇒ Object
Serialized setters and getters (rn or , separated)
54 55 56 |
# File 'app/models/concerns/compound_forms_label_extensions.rb', line 54 def inline_compound_form_origins @inline_compound_form_origins || [] end |
#inline_compound_form_origins=(value_collection) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'app/models/concerns/compound_forms_label_extensions.rb', line 58 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). reject(&:blank?).uniq end end |