Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #84 from stefanpenner/fix_attributes

[fixes #83] Translate generated attributes to ember-data compatible attributes
  • Loading branch information...
commit 8e2e339aaee1f3c32bd648d6fc60429e0ae7c725 2 parents d76bd79 + 144fd2a
Paul Chavard tchak authored

Showing 1 changed file with 20 additions and 2 deletions. Show diff stats Hide diff stats

  1. +20 2 lib/generators/ember/model_generator.rb
22 lib/generators/ember/model_generator.rb
@@ -13,12 +13,30 @@ def create_model_files
13 13 end
14 14
15 15 private
  16 + EMBER_TYPE_LOOKUP = {
  17 + nil => 'string',
  18 +
  19 + binary: 'string',
  20 + string: 'string',
  21 + text: 'string',
  22 + boolean: 'boolean',
  23 + date: 'date',
  24 + datetime: 'date',
  25 + time: 'date',
  26 + timestamp: 'date',
  27 + decimal: 'number',
  28 + float: 'number',
  29 + integer: 'number',
  30 + primary_key: 'number'
  31 + }
16 32
17 33 def parse_attributes!
18 34 self.attributes = (attributes || []).map do |attr|
19 35 name, type = attr.split(':')
20   - type = 'string' if type == 'text'
21   - { name: name, type: type }
  36 + key = type.try(:to_sym)
  37 + ember_type = EMBER_TYPE_LOOKUP[key] || type
  38 +
  39 + { name: name, type: ember_type }
22 40 end
23 41 end
24 42 end

0 comments on commit 8e2e339

Please sign in to comment.
Something went wrong with that request. Please try again.