Coder Social home page Coder Social logo

backbone.getters.setters's People

Contributors

berzniz avatar fredr avatar gillesruppert avatar jaseemabid avatar pumpikano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

backbone.getters.setters's Issues

License missing

I've been using this plugin in the past and only now came to realise that you haven't included a license at all, which means nobody but you is really allowed to use this legally.

If this is intended, it might be worth making a note of that in the README, but if it isn't it would be lovely if you could add a license such as MIT/BSD/WTFPL, so this can legitimately be used.

model.toJSON() method need to be overwritten

I think it would be productive if the toJSON () method was overridden so that getters include results as far as this only include the original attributes.

ย  something like this:

toJSON : function () {
           var gettersJSON = {};
            _.each(this.getters,function (getter,name) {
                if (_.isFunction(getter)) {
                     gettersJSON[name] = getter.call(this);
                }
            }.bind(this));
            return _.extend(Backbone.Model.prototype.toJSON.apply(this,arguments),gettersJSON);
}

Any interest in a "formatter" feature? and a bug...

The bug is related to prototyping object, which shouldn't be done, but is ๐Ÿ˜„, so worth watching out for:

// Go over all the set attributes and call the setter if available
for (attr in attrs) {}  # if Object.prototype has been changed, this will include those changes
for (attr in _(attrs).keys()) {}  // by the power of underscore, not no mo'.

The feature is one I baked into getters.setters today, that allows for a "formatter" to be passed into the getter/setters.

var m = new MyModel();
m.get('datetime');  // => Date object
m.get('datetime', 'time');  // => e.g. '13:45:12'
// WUH!?

var MyModel = Backbone.GSModel.extend({
  getters: {
    datetime: function(format) {
      var ret = this.rawget('datetime');  // also added, to make this easier.  calls Backbone.model.get.
      if ( format == 'time' ) {
        var time = ret.hour + ':' + ret.minute + ':' + ret.second;
        // real version has string padding, am/pm, etc.
        return time;
        }
      return ret;
    }
  }
});

If you're interested, I'll format this as a pull request.

[enhancement] Add missing bower.json.

Hey, maintainer(s) of berzniz/backbone.getters.setters!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library berzniz/backbone.getters.setters is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "berzniz/backbone.getters.setters",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

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.