Sha256: 44f60d1b28e89077a20acc2f26ab4d8b182291d6b22bb768036d5d09c044904e

Contents?: true

Size: 1.73 KB

Versions: 44

Compression:

Stored size: 1.73 KB

Contents

module Effective
  module Resources
    module Klass

      def klass
        @model_klass
      end

      def datatable_klass
        if defined?(EffectiveDatatables)
          "#{controller_path.classify.pluralize}Datatable".safe_constantize ||
          "#{controller_path.classify}Datatable".safe_constantize ||
          "#{namespaced_class_name.pluralize}Datatable".safe_constantize ||
          "#{namespaced_module_name.pluralize}Datatable".safe_constantize ||
          "#{namespaced_class_name.pluralize.gsub('::', '')}Datatable".safe_constantize ||
          "#{class_name.pluralize.camelize}Datatable".safe_constantize ||
          "#{class_name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize ||
          "#{name.pluralize.camelize}Datatable".safe_constantize ||
          "#{name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize ||
          "Effective::Datatables::#{namespaced_class_name.pluralize}".safe_constantize ||
          "Effective::Datatables::#{class_name.pluralize.camelize}".safe_constantize ||
          "Effective::Datatables::#{name.pluralize.camelize}".safe_constantize
        end
      end

      def controller_klass
        "#{namespaced_class_name.pluralize}Controller".safe_constantize ||
        "#{class_name.pluralize.classify}Controller".safe_constantize ||
        "#{name.pluralize.classify}Controller".safe_constantize ||
        "#{initialized_name.to_s.classify.pluralize}Controller".safe_constantize ||
        "#{initialized_name.to_s.classify}Controller".safe_constantize
      end

      def active_record?
        klass && klass.ancestors.include?(ActiveRecord::Base)
      end

      def active_model?
        klass && klass.ancestors.include?(ActiveModel::Model)
      end

    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
effective_resources-1.9.0 app/models/effective/resources/klass.rb
effective_resources-1.8.38 app/models/effective/resources/klass.rb
effective_resources-1.8.37 app/models/effective/resources/klass.rb
effective_resources-1.8.36 app/models/effective/resources/klass.rb
effective_resources-1.8.35 app/models/effective/resources/klass.rb
effective_resources-1.8.34 app/models/effective/resources/klass.rb
effective_resources-1.8.33 app/models/effective/resources/klass.rb
effective_resources-1.8.32 app/models/effective/resources/klass.rb
effective_resources-1.8.31 app/models/effective/resources/klass.rb
effective_resources-1.8.30 app/models/effective/resources/klass.rb
effective_resources-1.8.29 app/models/effective/resources/klass.rb
effective_resources-1.8.28 app/models/effective/resources/klass.rb
effective_resources-1.8.27 app/models/effective/resources/klass.rb
effective_resources-1.8.26 app/models/effective/resources/klass.rb
effective_resources-1.8.25 app/models/effective/resources/klass.rb
effective_resources-1.8.24 app/models/effective/resources/klass.rb
effective_resources-1.8.23 app/models/effective/resources/klass.rb
effective_resources-1.8.22 app/models/effective/resources/klass.rb
effective_resources-1.8.21 app/models/effective/resources/klass.rb
effective_resources-1.8.20 app/models/effective/resources/klass.rb