Sha256: f5f53969740ffb88b86ce1d2177cedc70ba3cb85bcbd6ed0b72fee1141483b23

Contents?: true

Size: 842 Bytes

Versions: 9

Compression:

Stored size: 842 Bytes

Contents

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

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

module EffectiveDatatables
  mattr_accessor :authorization_method

  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

9 entries across 9 versions & 1 rubygems

Version Path
effective_datatables-1.1.4 lib/effective_datatables.rb
effective_datatables-1.1.3 lib/effective_datatables.rb
effective_datatables-1.1.2 lib/effective_datatables.rb
effective_datatables-1.1.1 lib/effective_datatables.rb
effective_datatables-1.1.0 lib/effective_datatables.rb
effective_datatables-1.0.3 lib/effective_datatables.rb
effective_datatables-1.0.2 lib/effective_datatables.rb
effective_datatables-1.0.1 lib/effective_datatables.rb
effective_datatables-1.0.0 lib/effective_datatables.rb