Sha256: c366c4fd2b72c29572e623196145fb26ca11dedbb79e4d7f52f3f0f8f173829d

Contents?: true

Size: 1 KB

Versions: 21

Compression:

Stored size: 1 KB

Contents

require 'rails/generators/active_record'

module ActiveRecord
  module Generators
    class OauthConsumerGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path('../oauth_consumer_templates', __FILE__)

      # Implement the required interface for Rails::Generators::Migration.
      def self.next_migration_number(dirname) #:nodoc:
        next_migration_number = current_migration_number(dirname) + 1
        if ActiveRecord::Base.timestamped_migrations
          [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
        else
          "%.3d" % next_migration_number
        end
      end

      def check_class_collisions
        class_collisions '', %w(ConsumerToken)
      end

      def copy_models
        template 'consumer_token.rb', File.join('app/models', 'consumer_token.rb')
      end

      def copy_migration
        migration_template 'migration.rb', 'db/migrate/create_oauth_consumer_tokens'
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 6 rubygems

Version Path
oauth-plugin-0.4.0.pre2 lib/generators/active_record/oauth_consumer_generator.rb