Sha256: a24bd1fef16abe2d78074457bc1379912a4b9fdc14f924dbcda9a022d9a6fe4c
Contents?: true
Size: 855 Bytes
Versions: 3
Compression:
Stored size: 855 Bytes
Contents
require 'generators/pbw/resource_helpers' module Pbw module Generators class ModelGenerator < Rails::Generators::NamedBase include Pbw::Generators::ResourceHelpers argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" def create_backbone_model template "model.coffee", "#{backbone_path}/models/#{model_namespace.downcase}/#{file_name}.js.coffee" end def create_model generate "model", "#{model_namespace}::#{class_name} #{attributes.map{|attr| "#{attr.name}:#{attr.type}"}.join(' ')}" gsub_file "app/models/#{model_namespace.downcase}/#{file_name}.rb", "class #{model_namespace}::#{class_name}", "class #{model_namespace}::#{class_name} < #{base_model_class}" gsub_file "app/models/#{model_namespace.downcase}/#{file_name}.rb", "include Mongoid::Document", "" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pbw-0.1.1 | lib/generators/pbw/model_generator.rb |
pbw-0.1.0 | lib/generators/pbw/model_generator.rb |
pbw-0.0.10 | lib/generators/pbw/model_generator.rb |