Sha256: 351d06eb6852c4f90dd56f66b79b5fd6574616be3dd94671c3065c7f3312a099

Contents?: true

Size: 1.01 KB

Versions: 19

Compression:

Stored size: 1.01 KB

Contents

require 'rails/generators/active_record'
require 'generators/maestrano/orm_helpers'

module ActiveRecord
  module Generators
    class MaestranoGroupGenerator < ActiveRecord::Generators::Base
      include Maestrano::Generators::OrmHelpers
      source_root File.expand_path("../templates", __FILE__)
      
      def copy_maestrano_migration
        migration_template "migration.rb", "db/migrate/add_maestrano_to_#{table_name}.rb"
      end
      
      def inject_maestrano_content
        content = model_contents

        class_path = if namespaced?
          class_name.to_s.split("::")
        else
          [class_name]
        end

        indent_depth = class_path.size - 1
        content = content.split("\n").map { |line| "  " * indent_depth + line } .join("\n") << "\n"

        inject_into_class(model_path, class_path.last, content) if model_exists?
      end
      
      def migration_data
<<RUBY
      ## User source identification fields
      t.string :provider
      t.string :uid
RUBY
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
maestrano-rails-0.12.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.11.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.10.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.9.5 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.9.4 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-test-0.9.4 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-test-0.9.3 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.9.3 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.9.2 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.9.1 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.9.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.8.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.7.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.6.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.5.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.4.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.3.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.2.0 lib/generators/active_record/maestrano_group_generator.rb
maestrano-rails-0.1.0 lib/generators/active_record/maestrano_group_generator.rb