Class: ActiveRecord::Generators::ActsAsUserGenerator
Instance Method Summary
collapse
#migration_exists?, #migration_path, #model_exists?, #model_path
Instance Method Details
#copy_acts_as_user_migration ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/generators/active_record/acts_as_user_generator.rb', line 12
def copy_acts_as_user_migration
if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
migration_template "existing_migration.rb", "db/migrate/add_acts_as_user_to_#{table_name}"
else
migration_template "migration.rb", "db/migrate/creates_acts_as_user_to_#{table_name}"
end
end
|
#generate_model ⇒ Object
34
35
36
|
# File 'lib/generators/active_record/acts_as_user_generator.rb', line 34
def generate_model
invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke
end
|
#inject_is_user_content_to_user ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/generators/active_record/acts_as_user_generator.rb', line 20
def inject_is_user_content_to_user
content = %q{ is_user }
class_path = if namespaced?
class_name.to_s.split("::")
else
[class_name]
end
indent_depth = class_path.size - 1
content = content.split("\n").map { |line| " " * indent_depth + line } .join("\n") << "\n"
inject_into_class(model_path, class_path.last, content) if model_exists?
end
|