Sha256: 81804656bb1c35cc9ff3a260d753425cc142de7c9f585c6743c424ff164f8aeb

Contents?: true

Size: 906 Bytes

Versions: 7

Compression:

Stored size: 906 Bytes

Contents

require 'jquery-datatables-rails'
require 'kaminari'

require "effective_datatables/engine"
require "effective_datatables/version"

module EffectiveDatatables
  mattr_accessor :authorization_method
  mattr_accessor :date_format
  mattr_accessor :datetime_format

  def self.setup
    yield self
  end

  def self.authorized?(controller, action, resource)
    if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
      raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
    end
    true
  end

  def self.datatables
    Rails.env.development? ? read_datatables : (@@datatables ||= read_datatables)
  end

  private

  def self.read_datatables
    Rails.application.eager_load! unless Rails.configuration.cache_classes
    Effective::Datatable.descendants.map { |klass| klass }.compact
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
effective_datatables-1.2.4 lib/effective_datatables.rb
effective_datatables-1.2.3 lib/effective_datatables.rb
effective_datatables-1.2.2 lib/effective_datatables.rb
effective_datatables-1.2.1 lib/effective_datatables.rb
effective_datatables-1.2.0 lib/effective_datatables.rb
effective_datatables-1.1.6 lib/effective_datatables.rb
effective_datatables-1.1.5 lib/effective_datatables.rb