Sha256: 2b5c659249736d6748cb13de065f9d00a13ed1b3f7db050c31584fb39a659745

Contents?: true

Size: 731 Bytes

Versions: 2

Compression:

Stored size: 731 Bytes

Contents

require 'ember/version'

module Ember
  module Generators
    class ModelGenerator < ::Rails::Generators::NamedBase
      source_root File.expand_path("../../templates", __FILE__)
      argument :attributes, :type => :array, :default => [], :banner => "field[:type] field[:type] ..."

      desc "Creates a new Ember.js model"

      def create_model_files
        template 'model.js', File.join('app/assets/javascripts/models', class_path, "#{file_name}.js")
      end

    private

      def parse_attributes!
        self.attributes = (attributes || []).map do |attr|
          name, type = attr.split(':')
          type = 'string' if type == 'text'
          { name: name, type: type }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ember-rails-0.7.0 lib/generators/ember/model_generator.rb
ember-rails-0.6.0 lib/generators/ember/model_generator.rb