Sha256: b850abb57bc94d4ed812c5bea7727376aa0e1152f42a7be880b4eb39475a89b4

Contents?: true

Size: 985 Bytes

Versions: 23

Compression:

Stored size: 985 Bytes

Contents

module Naf
  class JanitorialDropAssignment < JanitorialAssignment
    # Protect from mass-assignment issue
    attr_accessible :model_name,
                    :assignment_order,
                    :enabled,
                    :deleted

    #--------------------
    # *** Validations ***
    #++++++++++++++++++++

    validate :deleted_enabled_check
    validates :assignment_order, numericality: {
                                   only_integer: true,
                                   greater_than_or_equal_to: 0,
                                   less_than: 2147483647
                                 }
    validates :model_name, presence: true

    #-------------------------
    # *** Instance Methods ***
    #+++++++++++++++++++++++++

    def do_janitorial_work(target_model)
      target_model.drop_old_partitions
    end

    def deleted_enabled_check
      if deleted && enabled
        errors.add(:deleted, "or Enabled must be false")
      end
    end

  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
naf-1.1.2 app/models/naf/janitorial_drop_assignment.rb
naf-1.1.1 app/models/naf/janitorial_drop_assignment.rb
naf-1.1.0 app/models/naf/janitorial_drop_assignment.rb