Sha256: eac4074e04939cbc7f8b496e5687c33792b39ee4ba059ad7f855ba42bc31851c

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

# frozen_sting_literals: true

module Effective
  module Resources
    module Generator

      def module_name
        return nil unless class_name.split('::').length > 1
        class_name.split('::').first
      end

      # Acpa
      def module_namespace
        return nil unless namespaces.present?
        Array(namespaces + [nil]).map { |name| name.to_s.classify } * '::'
      end

      # Admin::Courses
      def module_namespaced
        (Array(namespaces).map { |name| name.to_s.classify } + [plural_name.classify.pluralize]) * '::'
      end

      def namespaced_class_name # 'Admin::Effective::Post'
        (Array(namespaces).map { |name| name.to_s.classify } + [class_name]) * '::'
      end

      def namespaced_module_name # 'Admin::EffectivePosts'
        Array(namespaces).map { |name| name.to_s.classify }.join('::') + '::' + class_name.gsub('::', '')
      end

      # Tenants
      def tenant_controller_path
        (Tenant.module_name.downcase + '/' + controller_path) if tenant?
      end

      def tenant_namespaced_class_name
        (Tenant.module_name + '::' + namespaced_class_name) if tenant?
      end

      def tenant_namespaced_module_name
        (Tenant.module_name + '::' + namespaced_module_name) if tenant?
      end

      def tenant_class_name
        (Tenant.module_name + '::' + class_name) if tenant?
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
effective_resources-1.9.9 app/models/effective/resources/generator.rb
effective_resources-1.9.8 app/models/effective/resources/generator.rb
effective_resources-1.9.7 app/models/effective/resources/generator.rb
effective_resources-1.9.6 app/models/effective/resources/generator.rb
effective_resources-1.9.5 app/models/effective/resources/generator.rb
effective_resources-1.9.4 app/models/effective/resources/generator.rb
effective_resources-1.9.3 app/models/effective/resources/generator.rb