lib/ocean/ocean_application_controller.rb
#
# Cache values for collections. Accepts a class, a scope, or an array. 
# The cache value is based on three components: 
#   (1) the name of the class, 
#   (2) the number of members in the collection, and 
#   (3) the modification time of the last updated member.
# If an array is given, the class of the first member will be used to
# create a scope. If the array is empty, the optional second argument
# will be used as the class indicator.
#
Cache values for collections. Accepts a class, a scope, or an array.
The cache value is based on three components:
(1) the name of the class,
(2) the number of members in the collection, and
(3) the modification time of the last updated member.
If an array is given, the class of the first member will be used to
create a scope. If the array is empty, the optional second argument
will be used as the class indicator.
Cache values for collections . Accepts a class a scope or an array . The cache value is based on three components : ( 1 ) the name of the class ( 2 ) the number of members in the collection and ( 3 ) the modification time of the last updated member . If an array is given the class of the first member will be used to create a scope . If the array is empty the optional second argument will be used as the class indicator .
def collection_etag(coll, klass_name="_unknown_")
    if coll.is_a? Array
      return { etag: "#{klass_name}:0:0" } if coll == []
      coll = coll[0].class.where(id: coll.collect(&:id))
    end
    coll = add_right_restrictions(coll, @right_restrictions)
    klass = coll.name.constantize 
    timestamp = klass.update_timestamp || klass.create_timestamp
    if (timestamp)
      last_item = coll.reorder(timestamp).last
      last_updated = last_item ? last_item.send(timestamp).utc : 0
    else
      last_updated = 0
    end
    { etag: "#{coll.name}:#{coll.count}:#{last_updated}" }
  end
def collection_etag ( coll , klass_name = "_unknown_" ) if coll . is_a? Array return { etag : "#{klass_name}:0:0" } if coll == [ ] coll = coll [ 0 ] . class . where ( id : coll . collect ( & :id ) ) end coll = add_right_restrictions ( coll , @right_restrictions ) klass = coll . name . constantize timestamp = klass . update_timestamp || klass . create_timestamp if ( timestamp ) last_item = coll . reorder ( timestamp ) . last last_updated = last_item ? last_item . send ( timestamp ) . utc : 0 else last_updated = 0 end { etag : "#{coll.name}:#{coll.count}:#{last_updated}" } end
Cache values for collections.
Cache values for collections .
# Construct a new scope and fall through # Force a load of the class (for secondary collections)
coll
klass_name