Sha256: d1f12e6b7db6611d245b095fe7362e18f596d785ea9a072827bec3c103d59695

Contents?: true

Size: 797 Bytes

Versions: 9

Compression:

Stored size: 797 Bytes

Contents

class PublishingGenerator < Rails::Generator::Base

  attr_reader :publishing_class
  attr_reader :publishing_table_name

  def initialize(args, options = {})
    klass = args.last

    begin; valid_klass = klass.camelcase.constantize; rescue; end

    if valid_klass
      @publishing_table_name = klass.to_s.downcase.pluralize
      @publishing_class = klass.to_s.capitalize
    else
      raise "#{klass} is not a valid class in this application."
    end
  
    super
  end

  def manifest
    record do |m|
      unless options[:skip_migration]
        m.migration_template 'migration.rb', 'db/migrate',
          :migration_file_name => "add_published_as_to_#{@publishing_table_name}"
      end
    end
  end

  protected
  def usage
    puts "Usage: #{$0} publishing [ModelName]"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
community_engine-3.0.0 vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.3.2 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.3.1 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.3.0 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.1.0 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.0.0 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.0.0.beta3 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.0.0.beta2 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb
community_engine-2.0.0.beta1 vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb