Sha256: dac332fcf0b7e0bde7dd88a55012fd5e9b9596878a7f207413b2481e2c5beb89

Contents?: true

Size: 1 KB

Versions: 13

Compression:

Stored size: 1 KB

Contents

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

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

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

      def generate(headless:, name:)
        policy = Inflect.new(:policy, name)
        config = {class_name: policy.class_name, resource: policy.resource, constant: policy.constant, headless: headless}
        template('policy.tt', policy.file_path, config)
      end

      def generate_policy_roles_migration(policy:)
        sleep 1
        migration = Eucalypt::Helpers::Migration[title: "create_#{policy}_roles", template: 'create_policy_roles_migration.tt']
        return unless migration.create_anyway? if migration.exists?
        config = {migration_title: migration.title.camelize, policy: policy}
        template migration.template, migration.file_path, config
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
eucalypt-0.5.0 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.4.2 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.4.1 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.4.0 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.3.5 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.3.4 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.3.3 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.3.2 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.3.1 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.3.0 lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
eucalypt-0.2.2 lib/eucalypt/eucalypt-security/namespaces/security-policy/generators/policy.rb
eucalypt-0.2.1 lib/eucalypt/eucalypt-security/namespaces/security-policy/generators/policy.rb
eucalypt-0.2.0 lib/eucalypt/eucalypt-security/namespaces/security-policy/generators/policy.rb