Sha256: 0a9a6ac8fb13c7069230463d94f8b7f209ba4529b0436299505e765b0cfeb55c

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Effective
  module Resources
    module Klass

      def klass
        @model_klass
      end

      def datatable_klass
        if defined?(EffectiveDatatables)
          "#{namespaced_class_name.pluralize}Datatable".safe_constantize ||
          "#{class_name.pluralize.camelize}Datatable".safe_constantize ||
          "#{name.pluralize.camelize}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.ancestors.include?(ActiveRecord::Base)
      end

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

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
effective_resources-1.1.3 app/models/effective/resources/klass.rb
effective_resources-1.1.2 app/models/effective/resources/klass.rb
effective_resources-1.1.1 app/models/effective/resources/klass.rb
effective_resources-1.1.0 app/models/effective/resources/klass.rb