Sha256: 53fee6fdfef61f38afbc597485f1fd733574d6dedc70bfc38fa7b3868bb87830

Contents?: true

Size: 473 Bytes

Versions: 154

Compression:

Stored size: 473 Bytes

Contents

require 'rails/generators'

module CmAdmin
  module Generators
    class PolicyGenerator < Rails::Generators::NamedBase
      source_root File.expand_path('templates', __dir__)

      def copy_policy_files
        @cm_model = CmAdmin::Model.find_by({name: file_name.classify})
        raise "cm_admin is not defined inside #{file_name} model" unless @cm_model.present?
        template "policy.rb", "app/policies/cm_admin/#{file_name}_policy.rb"
      end
    end
  end
end

Version data entries

154 entries across 154 versions & 1 rubygems

Version Path
cm-admin-1.3.4 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.3.3 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.3.2 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.3.1 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.3.0 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.9 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.8 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.7 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.6 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.5 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.4 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.3 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.2 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.1 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.2.0 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.9 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.8 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.7 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.6 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.5 lib/generators/cm_admin/policy_generator.rb