class ReferableGenerator
Public Instance Methods
add_class_to_referable_reward()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/generators/referable/referable_generator.rb, line 19 def setup_migrations create_model_migration create_reward_migration end
Private Instance Methods
acquireable_by_empty?()
click to toggle source
# File lib/generators/referable/referable_generator.rb, line 38 def acquireable_by_empty? File.read('app/models/referable_reward.rb').include? 'acquireable_by: []' end