Sha256: 8b6b823191538a3c95bf249ab5ac8c5f8c494515c00f278e8da46922dbddf5d3

Contents?: true

Size: 967 Bytes

Versions: 58

Compression:

Stored size: 967 Bytes

Contents

pageflow.FileTypesCollection = pageflow.Object.extend({
  initialize: function(fileTypes) {
    this._fileTypes = fileTypes;
  },

  findByUpload: function(upload) {
    var result = this.find(function(fileType) {
      return fileType.matchUpload(upload);
    });

    if (!result) {
      throw(new pageflow.UnmatchedUploadError(upload));
    }

    return result;
  },

  findByCollectionName: function(collectionName) {
    var result = this.find(function(fileType) {
      return fileType.collectionName === collectionName;
    });

    if (!result) {
      throw('Could not find file type by collection name "' + collectionName +'"');
    }

    return result;
  }
});

_.each(['each', 'map', 'reduce', 'first', 'find', 'contains', 'filter'], function(method) {
  pageflow.FileTypesCollection.prototype[method] = function() {
    var args = Array.prototype.slice.call(arguments);
    args.unshift(this._fileTypes);
    return _[method].apply(_, args);
  };
});

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
pageflow-14.5.2 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.2 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.1 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.0 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.5.1 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.5.0 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.0.rc2 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.0.rc1 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.0.beta4 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.0.beta3 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.4.0 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.0.beta2 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-15.0.0.beta1 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.3.0 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.2.1 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.2.0 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.1.1 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.1.0 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.0.0 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js
pageflow-14.0.0.rc2 app/assets/javascripts/pageflow/editor/collections/file_types_collection.js