Sha256: acf068b2409543e371a9818d761ce6732e7a70c475d1aca07b346878d89192d0

Contents?: true

Size: 906 Bytes

Versions: 12

Compression:

Stored size: 906 Bytes

Contents

require 'kaminari'

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

module EffectiveDatatables
  mattr_accessor :authorization_method
  mattr_accessor :date_format
  mattr_accessor :datetime_format
  mattr_accessor :default_entries

  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

12 entries across 12 versions & 1 rubygems

Version Path
effective_datatables-1.8.3 lib/effective_datatables.rb
effective_datatables-1.8.2 lib/effective_datatables.rb
effective_datatables-1.8.1 lib/effective_datatables.rb
effective_datatables-1.8.0 lib/effective_datatables.rb
effective_datatables-1.7.1 lib/effective_datatables.rb
effective_datatables-1.7.0 lib/effective_datatables.rb
effective_datatables-1.6.3 lib/effective_datatables.rb
effective_datatables-1.6.2 lib/effective_datatables.rb
effective_datatables-1.6.1 lib/effective_datatables.rb
effective_datatables-1.6.0 lib/effective_datatables.rb
effective_datatables-1.5.1 lib/effective_datatables.rb
effective_datatables-1.5.0 lib/effective_datatables.rb