Sha256: 1b4205d04decd6cfc8173152156aa7f510373978cfbc3eaee0a6baef6ee05019

Contents?: true

Size: 994 Bytes

Versions: 4

Compression:

Stored size: 994 Bytes

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(name:)
        policy = Inflect.new(:policy, name)
        config = {class_name: policy.class_name, resource: policy.resource, constant: policy.constant}
        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

4 entries across 4 versions & 1 rubygems

Version Path
eucalypt-0.1.3 lib/eucalypt/eucalypt-security/namespaces/security-policy/generators/policy.rb
eucalypt-0.1.2 lib/eucalypt/eucalypt-security/namespaces/security-policy/generators/policy.rb
eucalypt-0.1.1 lib/eucalypt/eucalypt-security/namespaces/security-policy/generators/policy.rb
eucalypt-0.1.0 lib/eucalypt/eucalypt-security/namespaces/security-policy/generators/policy.rb