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.1.4 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.3 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.2 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.1 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.1.0 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.9 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.8 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.7 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.6 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.5 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.3 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.2 lib/generators/cm_admin/policy_generator.rb
cm-admin-1.0.0 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.9.1 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.9.0 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.8.9 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.8.8 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.8.7 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.8.6 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.8.5 lib/generators/cm_admin/policy_generator.rb