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_nii-0.1.0.pre spec/dummy/lib/master_model.rb
enju_subject-0.1.0.pre4 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre3 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre2 lib/enju_subject/master_model.rb
enju_subject-0.1.0.pre lib/enju_subject/master_model.rb
enju_subject-0.0.18 lib/enju_subject/master_model.rb
enju_subject-0.0.17 lib/enju_subject/master_model.rb
enju_subject-0.0.16 lib/enju_subject/master_model.rb
enju_bookmark-0.0.19 lib/enju_bookmark/master_model.rb
enju_event-0.0.24 spec/dummy/lib/enju_leaf/master_model.rb
enju_bookmark-0.0.18 lib/enju_bookmark/master_model.rb
enju_event-0.0.23 spec/dummy/lib/enju_leaf/master_model.rb
enju_event-0.1.10 spec/dummy/lib/enju_leaf/master_model.rb
enju_event-0.1.9 spec/dummy/lib/enju_leaf/master_model.rb
enju_event-0.0.22 spec/dummy/lib/enju_leaf/master_model.rb
enju_subject-0.0.15 lib/enju_subject/master_model.rb
enju_event-0.0.21 spec/dummy/lib/enju_leaf/master_model.rb
enju_event-0.1.8 spec/dummy/lib/enju_leaf/master_model.rb
enju_message-0.0.23 spec/dummy/lib/enju_leaf/master_model.rb
enju_message-0.1.7 spec/dummy/lib/enju_leaf/master_model.rb