Module: Effective::EffectiveDatatable::Collection

Included in:
Datatable
Defined in:
app/models/effective/effective_datatable/collection.rb

Instance Method Summary collapse

Instance Method Details

#active_record_array_collection?Boolean

User<1>, User<2>, Post<1>, Page<3>

Returns:

  • (Boolean)


18
19
20
# File 'app/models/effective/effective_datatable/collection.rb', line 18

def active_record_array_collection?
  @active_record_array_collection == true
end

#active_record_collection?Boolean

User.all

Returns:

  • (Boolean)


13
14
15
# File 'app/models/effective/effective_datatable/collection.rb', line 13

def active_record_collection?
  @active_record_collection == true
end

#active_record_polymorphic_array_collection?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'app/models/effective/effective_datatable/collection.rb', line 22

def active_record_polymorphic_array_collection?
  return false unless active_record_array_collection?
  return @active_record_polymorphic_array_collection unless @active_record_polymorphic_array_collection.nil?
  @active_record_polymorphic_array_collection = collection.map { |obj| obj.class }.uniq.length > 1
end

#array_collection?Boolean

[1, ‘foo’], [2, ‘bar’]

Returns:

  • (Boolean)


29
30
31
# File 'app/models/effective/effective_datatable/collection.rb', line 29

def array_collection?
  @array_collection == true
end

#collection_classObject

Used for authorization. We authorize with authorized?(:index, collection_class)



8
9
10
# File 'app/models/effective/effective_datatable/collection.rb', line 8

def collection_class
  @collection_class  # Will be either User/Post/etc or Array
end