Code Monkey home page Code Monkey logo

Comments (6)

webpro avatar webpro commented on May 12, 2024

Agreed, good idea. Any chance you could submit a PR? Not sure when I have time for this.—
Sent from Mailbox

On Sat, May 31, 2014 at 10:09 PM, Terin Stock [email protected]
wrote:

It would be nice if collection could be a function, allowing the same file to render a collection and an individual member.

Reply to this email directly or view it on GitHub:
#25

from dyson.

webpro avatar webpro commented on May 12, 2024

Looking into this, I'm not sure if it makes sense to implement the requested feature. I don't think collection() is supposed to return the actual data.

Perhaps something like the following would work (i.e. reuse template for both endpoints)?

var g = require('dyson-generators');

var dummy = {
    path: '/dummy/:id',
    template: {
        id: function(params) {
            return params.id || g.id();
        },
        status: 'OK'
    }
};

var dummies = {
    path: '/dummy/',
    collection: true,
    template: dummy.template
};

module.exports = [dummy, dummies];

Otherwise, what is your specific use case?

from dyson.

terinjokes avatar terinjokes commented on May 12, 2024

It depends on the specific type of API you're mocking, sending back the initial collection data is fairly common.

But yes, I'll send a pull.

from dyson.

webpro avatar webpro commented on May 12, 2024

So I guess you mean just this (i.e. _.result()):

collection: function(params) {
    return conditionPerhapsUsingParams ? true : false;
}

That should be easy.

from dyson.

webpro avatar webpro commented on May 12, 2024

@terinjokes I missed your "pull" part, I implemented/released something that hopefully matches your needs. Can we close this?

from dyson.

webpro avatar webpro commented on May 12, 2024

Released in v0.3.1.

from dyson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.