Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@tchak tchak authored
Showing with 20 additions and 2 deletions.
  1. +20 −2 lib/generators/ember/model_generator.rb
View
22 lib/generators/ember/model_generator.rb
@@ -13,12 +13,30 @@ def create_model_files
end
private
+ EMBER_TYPE_LOOKUP = {
+ nil => 'string',
+
+ binary: 'string',
+ string: 'string',
+ text: 'string',
+ boolean: 'boolean',
+ date: 'date',
+ datetime: 'date',
+ time: 'date',
+ timestamp: 'date',
+ decimal: 'number',
+ float: 'number',
+ integer: 'number',
+ primary_key: 'number'
+ }
def parse_attributes!
self.attributes = (attributes || []).map do |attr|
name, type = attr.split(':')
- type = 'string' if type == 'text'
- { name: name, type: type }
+ key = type.try(:to_sym)
+ ember_type = EMBER_TYPE_LOOKUP[key] || type
+
+ { name: name, type: ember_type }
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.