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

Version Path
enju_subject-0.1.1 lib/enju_subject/master_model.rb
enju_subject-0.1.0 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre34 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre33 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre32 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre31 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre30 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre29 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre28 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre27 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre26 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre25 lib/enju_subject/master_model.rb
enju_trunk_subject-1.0.4 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre24 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre23 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre22 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre21 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre20 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre19 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre18 lib/enju_subject/master_model.rb