Sha256: dc37bb80d4cf05ff6298d88f20e61f101535b56f5f9e02e5dc6e57bae2af15da

Contents?: true

Size: 858 Bytes

Versions: 28

Compression:

Stored size: 858 Bytes

Contents

require 'active_support'
require 'active_support/core_ext'
require 'thor'
require 'eucalypt/helpers'

module Eucalypt
  module Generators
    class PolicyPermission < Thor::Group
      include Thor::Actions
      include Eucalypt::Helpers

      def self.source_root
        File.join File.dirname(__dir__), 'templates'
      end

      def generate(policy_name:, permission:)
        sleep 1
        migration = Eucalypt::Helpers::Migration[
          title: "add_#{permission}_permission_to_#{policy_name}_policy",
          template: 'add_permission_to_policy_migration.tt'
        ]
        return unless migration.create_anyway? if migration.exists?
        config = {migration_title: migration.title.camelize, policy_name: policy_name, permission: permission}
        template migration.template, migration.file_path, config
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
eucalypt-0.8.0 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.7.2 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.7.1 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.7.0 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.6.2 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.6.1 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.6.0 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.5.4 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.5.3 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.5.2 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.5.1 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.5.0 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.4.2 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.4.1 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.4.0 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.3.5 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.3.4 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.3.3 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.3.2 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb
eucalypt-0.3.1 lib/eucalypt/security/namespaces/security-policy-permission/generators/policy-permission.rb