Module: Katello::Ext::LabelFromName
- Included in:
- AlternateContentSource, ContentView, KTEnvironment, Product, RootRepository
- Defined in:
- app/models/katello/ext/label_from_name.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 |
# File 'app/models/katello/ext/label_from_name.rb', line 4 def self.included(base) base.class_eval do before_validation :setup_label_from_name validate :label_not_changed, :on => :update end end |
Instance Method Details
#label_not_changed ⇒ Object
20 21 22 23 24 |
# File 'app/models/katello/ext/label_from_name.rb', line 20 def label_not_changed if label_changed? && label_was.present? errors.add(:label, _("cannot be changed.")) end end |
#setup_label_from_name ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/models/katello/ext/label_from_name.rb', line 11 def setup_label_from_name if label.blank? self.label = Util::Model.labelize(name) if self.class.where(:label => self.label).any? self.label = Util::Model.uuid end end end |