lib/padrino-gen/generators/components/orms/mongoid.rb in padrino-gen-0.9.24 vs lib/padrino-gen/generators/components/orms/mongoid.rb in padrino-gen-0.9.25

- old
+ new

@@ -26,11 +26,12 @@ # More installation and setup notes are on http://mongoid.org/docs/ MONGO def setup_orm require_dependencies 'bson_ext', :require => 'mongo' - require_dependencies 'mongoid', :version => '2.0.0.beta.20' + require_dependencies 'mongoid', :version => '2.0.0' + require_dependencies 'SystemTimer', :require => 'system_timer' create_file("config/database.rb", MONGOID.gsub(/!NAME!/, @app_name.underscore)) empty_directory('app/models') end MONGOID_MODEL = (<<-MODEL) unless defined?(MONGOID_MODEL) @@ -44,19 +45,18 @@ # You can define indexes on documents using the index macro: # index :field <, :unique => true> # You can create a composite key in mongoid to replace the default id using the key macro: # key :field <, :another_field, :one_more ....> - end MODEL # options => { :fields => ["title:string", "body:string"], :app => 'app' } def create_model_file(name, options={}) model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb") - field_tuples = options[:fields].collect { |value| value.split(":") } - column_declarations = field_tuples.collect { |field, kind| "field :#{field}, :type => #{kind.camelize}" }.join("\n ") + field_tuples = options[:fields].map { |value| value.split(":") } + column_declarations = field_tuples.map { |field, kind| "field :#{field}, :type => #{kind.camelize}" }.join("\n ") model_contents = MONGOID_MODEL.gsub(/!NAME!/, name.to_s.camelize) model_contents.gsub!(/!FIELDS!/, column_declarations) create_file(model_path, model_contents) end @@ -64,6 +64,6 @@ # NO MIGRATION NEEDED end def create_migration_file(migration_name, name, columns) # NO MIGRATION NEEDED -end +end \ No newline at end of file