Sha256: 8976481be121d541b94118cea5320ce114833d30cdee50b5254d7bea90f2540f

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

total_entries = nil
current_page_entries = 0
collection ||= nil

instance_variables.each do |vn|
  v = instance_variable_get(vn)
  
  # if a collection variable was specified, use it only
  next if collection && collection != v
  
  next if v.class.name.nil?
  if v.class.name.start_with?("MetaSearch::Searches") and v.respond_to?('size')
    current_page_entries = v.size
  end
  if v.class.name.start_with?("ActiveRecord::Relation") and v.respond_to?('size')
    current_page_entries = v.size
  end
  if v.class.name.start_with?("Array") and v.respond_to?('size') and (current_page_entries == 0)
    current_page_entries = v.size
  end

  if v.class.name.start_with?("Mongoid::Criteria")
    total_entries = v.length
    break;
  end

  if v.respond_to?('total_entries')
    total_entries = v.total_entries
    current_page_entries = v.size
    break
  end
end

total_entries = current_page_entries if total_entries.nil?

json.iTotalRecords current_page_entries
json.iTotalDisplayRecords total_entries
json.sEcho params["sEcho"].to_i
json.aaData do
  json.ingest! yield
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_datatables-0.2.0 app/views/layouts/application.datatables.jsonify