Sha256: 53fee6fdfef61f38afbc597485f1fd733574d6dedc70bfc38fa7b3868bb87830

Contents?: true

Size: 473 Bytes

Versions: 152

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

152 entries across 152 versions & 1 rubygems

Version Path
cm-admin-1.5.55 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.54 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.53 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.52 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.51 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.50 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.49 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.48 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.47 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.46 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.45 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.44 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.43 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.42 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.41 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.40 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.39 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.38 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.37 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.5.36 lib/generators/cm_admin/policy_generator.rb