Sha256: c07da5de51aa37d33b05ade32f2afc7742c91c5e88d4f1af79cb3f1616435afa

Contents?: true

Size: 764 Bytes

Versions: 8

Compression:

Stored size: 764 Bytes

Contents

class RioModelGenerator < Rails::Generator::NamedBase
  def manifest
    if (@args.size == 0)
      begin
        attributes = class_name.constantize.column_names - ["id", "created_at", "updated_at"]
      rescue
        attributes = []
      end
    else
      attributes = @args.map {|arg| arg.match(/(.*):.*/)[1] }
    end

    record do |m|
      m.template "model.js", "public/javascripts/models/#{file_name}.js", :assigns => { :attributes => attributes }
      m.directory "public/javascripts/specs/fixtures/models"
      m.template "fixture.js", "public/javascripts/specs/fixtures/models/#{file_name}.js"
      m.directory "public/javascripts/specs/models"
      m.template "spec.js", "public/javascripts/specs/models/#{file_name}_spec.js"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
riojs-0.0.7 generators/rio_model/rio_model_generator.rb
riojs-0.0.6 generators/rio_model/rio_model_generator.rb
riojs-0.0.5 generators/rio_model/rio_model_generator.rb
riojs-0.0.4 generators/rio_model/rio_model_generator.rb
riojs-0.0.3 generators/rio_model/rio_model_generator.rb
riojs-0.0.2 generators/rio_model/rio_model_generator.rb
riojs-0.0.1 generators/rio_model/rio_model_generator.rb
riojs-0.0.0 generators/rio_model/rio_model_generator.rb