class Merit::Generators::MeritGenerator

Public Instance Methods

inject_merit_content() click to toggle source
# File lib/merit/generators/merit_generator.rb, line 8
def inject_merit_content
  if model_exists?
    inject_into_class(model_path, class_name, "  ### END ###\n\n")
    inject_into_class(model_path, class_name, "  has_many :created_badges, class_name: 'Merit::Badge', :dependent => :destroy\n")
    inject_into_class(model_path, class_name, "  has_many :assigned_badges, through: :sash, source: :badges, :dependent => :destroy\n")
    inject_into_class(model_path, class_name, "  belongs_to :sash, foreign_key: 'sash_id', class_name: 'Merit::Sash', :dependent => :destroy\n")
    inject_into_class(model_path, class_name, "  has_merit\n")
    inject_into_class(model_path, class_name, "  ### QALAM_MERIT ###\n")

    inject_into_class(course_path, "Course", "  ### END ###\n\n")
    inject_into_class(course_path, "Course", "  has_many :badges_sashes, class_name: 'Merit::BadgesSash', dependent: :destroy\n")
    inject_into_class(course_path, "Course", "  has_many :score_points, class_name: 'Merit::QalamScore::Point', dependent: :destroy\n")
    inject_into_class(course_path, "Course", "  ### QALAM_MERIT ###\n")
  end
end
run_active_record_generators() click to toggle source
# File lib/merit/generators/merit_generator.rb, line 24
def run_active_record_generators
  invoke 'merit:active_record:merit'
end

Private Instance Methods

course_path() click to toggle source
# File lib/merit/generators/merit_generator.rb, line 38
def course_path
  @course_path ||= File.join('app', 'models', "course.rb")
end
model_exists?() click to toggle source
# File lib/merit/generators/merit_generator.rb, line 30
def model_exists?
  File.exist? File.join(destination_root, model_path)
end
model_path() click to toggle source
# File lib/merit/generators/merit_generator.rb, line 34
def model_path
  @model_path ||= File.join('app', 'models', "#{file_path}.rb")
end