Class: ReferableGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- ReferableGenerator
show all
- Includes:
- Migrations
- Defined in:
- lib/generators/referable/referable_generator.rb
Instance Method Summary
collapse
Methods included from Migrations
#last_migration, #migration_created?
#create_reward_migration
#create_model_migration
Instance Method Details
#add_class_to_referable_reward ⇒ Object
30
31
32
33
34
|
# File 'lib/generators/referable/referable_generator.rb', line 30
def add_class_to_referable_reward
symbol_in_array = acquireable_by_empty? ? ":#{file_name}" : ", :#{file_name}"
inject_into_file('app/models/referable_reward.rb',
before: '], _prefix: :acquireable_by') { symbol_in_array }
end
|
#copy_referable_concern ⇒ Object
14
15
16
17
|
# File 'lib/generators/referable/referable_generator.rb', line 14
def copy_referable_concern
copy_file "concerns/referable.rb", "app/models/concerns/referable.rb"
copy_file "model/referable_reward.rb", "app/models/referable_reward.rb"
end
|
#copy_referral ⇒ Object
10
11
12
|
# File 'lib/generators/referable/referable_generator.rb', line 10
def copy_referral
copy_file "model/referral.rb", "app/models/referral.rb"
end
|
#include_concern_in_class ⇒ Object
24
25
26
27
28
|
# File 'lib/generators/referable/referable_generator.rb', line 24
def include_concern_in_class
inject_into_file "app/models/#{file_name}.rb", after: 'User < ApplicationRecord' do
"\n include Referable"
end
end
|
#setup_migrations ⇒ Object
19
20
21
22
|
# File 'lib/generators/referable/referable_generator.rb', line 19
def setup_migrations
create_model_migration
create_reward_migration
end
|