Method: CurationConcerns::ModelsGenerator#inject_curation_concerns_user_behavior

Defined in:
lib/generators/curation_concerns/models_generator.rb

#inject_curation_concerns_user_behaviorObject

Add behaviors to the user model



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/curation_concerns/models_generator.rb', line 19

def inject_curation_concerns_user_behavior
  file_path = "app/models/#{model_name.underscore}.rb"
  if File.exist?(file_path)
    inject_into_file file_path, after: /include Hydra\:\:User.*$/ do
      "\n  # Connects this user object to Curation Concerns behaviors." \
      "\n  include CurationConcerns::User\n"
    end
  else
    puts "     \e[31mFailure\e[0m  CurationConcerns requires a user object. This generators assumes that the model is defined in the file #{file_path}, which does not exist.  If you used a different name, please re-run the generator and provide that name as an argument. Such as \b  rails -g curation_concerns client"
  end
end