Sha256: 90f4ad9569e5f701b516c8ccb2878f955518aa6c899e561cfab7a4890e676470
Contents?: true
Size: 827 Bytes
Versions: 145
Compression:
Stored size: 827 Bytes
Contents
module MasterModel def self.included(base) #base.extend ClassMethods base.send :include, InstanceMethods base.class_eval do acts_as_list validates_uniqueness_of :name, :case_sensitive => false validates_presence_of :name, :display_name before_validation :set_display_name, :on => :create normalize_attributes :name end end module InstanceMethods def set_display_name self.display_name = self.name if self.display_name.blank? end def check_creatable if creatable? raise NotModifiableError end end def check_deletable if deletable? raise NotModifiableError end end def creatable? false end def deletable? false end end class NotModifiableError < StandardError; end end
Version data entries
145 entries across 145 versions & 8 rubygems