You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

ember-enum

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

ember-enum

This addon provides a very simple abstraction to use enum attributes with ember data.

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Ember Enum

Build Status Ember Observer Score

This addon provides a very simple abstraction to use enum attributes with ember data.

Installation

ember install ember-enum

Usage

You can define an enum attribute as follows:

import Model from 'ember-data/model';
import attr from 'ember-data/attr';

export default Model.extend({
  status: attr('enum', {
    options: [
      'started',
      'stopped'
    ],
    defaultValue: 'started'
  })
});

The value from the json response is expected to be a string. Now you can use the attribute in templates:

{{model.status.value}}

You can also use boolean methods to check if the enum has a certain value:

{{#if model.status.isStarted}}
  Started!
{{/if}}

You can use a select element like this:

<select value={{model.status.value}} onchange={{action (mut model.status.value) value="target.value"}}>
  {{#each model.status.options as |option|}}
    <option value={{option}}>{{option}}</option>
  {{/each}}
</select>

Limitations

This project only works with ember-data 2.5 and higher.

License

This project is released under the MIT License.

Keywords

ember-addon

FAQs

Package last updated on 02 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts