Class: Ecko::Plugins::Sponsor::DonationPackageGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/ecko/plugins/sponsor/generator/donation_package_generator.rb

Constant Summary collapse

DATA_TYPES =
%w(binary json jsonb).freeze

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ DonationPackageGenerator

Returns a new instance of DonationPackageGenerator.



23
24
25
26
27
28
29
# File 'lib/ecko/plugins/sponsor/generator/donation_package_generator.rb', line 23

def initialize(*args)
  super

  if DATA_TYPES.exclude?(options.fetch(:data_type))
    raise Error, "Invalid value for --data-type option. Supported for options are: #{DATA_TYPES.join(", ")}."
  end
end

Instance Method Details

#create_migrationObject

THis will help in generating new templates for donations service.



32
33
34
35
36
# File 'lib/ecko/plugins/sponsor/generator/donation_package_generator.rb', line 32

def create_migration
  template 'create_donation_package_template.rb', "db/migrate/#{timestamp}_create_donation_packages.rb"
  template 'donation_package.rb', 'app/models/donation_package.rb'
  template 'donation.rb', 'app/models/donation.rb'
end