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-0.8.2 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.8.1 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.8.0 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.8 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.7 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.6 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.5 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.4 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.3 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.2 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.1 lib/generators/cm_admin/policy_generator.rb
cm-admin-0.7.0 lib/generators/cm_admin/policy_generator.rb