Sha256: 2f00346f1bd959244ba39d48b22c3d6e5aed5e0a55f102e3a920250b59faca63

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

require 'generators/cantango/base'

module Cantango
  module Generators
    class PermissionGenerator < Cantango::Generators::Base
      desc "Creates a Permission for a model in 'app/models'"

      argument     :name,       :type => :string,
          :desc => "Model to create Permission model for"

      source_root File.dirname(__FILE__) + '/templates'

      def main_flow
        relational
      end

      def relational
        Rails::Generators.invoke "model", ['Permission', "#{name}_id:integer", "thing_id:integer", "thing_type:string", "action:string"

        puts "Manual Modifications to Permission model:"
        puts "-----------------------------------------"
        puts "belongs_to :#{name}"
        puts "belongs_to :thing, :polymorphic => true"

        puts "Manual Modifications to #{name.to_s.camelize} model:"
        puts "has_many :permissions"
        puts "-----------------------------------------"

        puts "and then run:"
        puts "rake db:migrate"
      end

      def document_store
        Rails::Generators.invoke "model", ['Permission']
        # use rails_artifactor to edit model?!
      end

      protected

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cantango-0.9.4.7 lib/generators/cantango/permission/permission_generator.rb
cantango-0.9.4.6 lib/generators/cantango/permission/permission_generator.rb
cantango-0.9.4.5 lib/generators/cantango/permission/permission_generator.rb
cantango-0.9.4.3 lib/generators/cantango/permission/permission_generator.rb
cantango-0.9.4.2 lib/generators/cantango/permission/permission_generator.rb
cantango-0.9.4.1 lib/generators/cantango/permission/permission_generator.rb
cantango-0.9.4 lib/generators/cantango/permission/permission_generator.rb
cantango-0.9.3.2 lib/generators/cantango/permission/permission_generator.rb