mongomodel 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ module MongoModel
6
6
  include ActiveModel::Dirty
7
7
 
8
8
  included do
9
+ before_save { @previously_changed = changes }
9
10
  after_save { changed_attributes.clear }
10
11
  end
11
12
 
@@ -18,5 +18,13 @@ module MongoModel
18
18
  MongoModel.configuration = mongomodel_configuration[Rails.env]
19
19
  end
20
20
  end
21
+
22
+ initializer "mongomodel.passenger_forking" do |app|
23
+ if defined?(PhusionPassenger)
24
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
25
+ MongoModel.database.connection.connect if forked
26
+ end
27
+ end
28
+ end
21
29
  end
22
30
  end
@@ -1,3 +1,3 @@
1
1
  module MongoModel
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'rails/generators/base'
2
+
3
+ module MongoModel
4
+ module Generators
5
+ class ConfigGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ argument :database, :type => :string, :default => 'mongomodel_default'
9
+
10
+ def create_files
11
+ template "mongomodel.yml" , "config/mongomodel.yml"
12
+ end
13
+
14
+ def self.banner
15
+ "rails generate mongo_model:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ defaults: &defaults
2
+ host: localhost
3
+ # port: 27017
4
+
5
+ development:
6
+ <<: *defaults
7
+ database: <%= database %>_development
8
+
9
+ test:
10
+ <<: *defaults
11
+ database: <%= database %>_test
12
+
13
+ production:
14
+ <<: *defaults
15
+ database: <%= database %>_production
16
+ # host:
17
+ # username:
18
+ # password:
19
+ # pool_size:
20
+ # timeout:
21
+
@@ -0,0 +1,22 @@
1
+ require 'rails/generators/base'
2
+
3
+ module MongoModel
4
+ module Generators
5
+ class ModelGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
9
+
10
+ class_option :timestamps, :type => :boolean, :aliases => "-T", :default => true, :desc => "Add timestamp fields (created_at, updated_at)"
11
+ class_option :embedded, :type => :boolean, :aliases => "-E", :default => false, :desc => "Inherit from EmbeddedDocument"
12
+
13
+ check_class_collision
14
+
15
+ def create_model_file
16
+ template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
17
+ end
18
+
19
+ hook_for :test_framework
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ class <%= class_name %> < MongoModel::<%= "Embedded" if options[:embedded] %>Document
2
+ <%- attributes.each do |a| -%>
3
+ <%= "property :#{a.name}, #{a.type.capitalize}" %>
4
+ <%- end -%>
5
+ <%= "timestamps!" if options[:timestamps] && !options[:embedded] %>
6
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongomodel}
8
- s.version = "0.2.7"
8
+ s.version = "0.2.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sam Pohlenz"]
12
- s.date = %q{2010-09-05}
12
+ s.date = %q{2010-09-06}
13
13
  s.default_executable = %q{console}
14
14
  s.description = %q{MongoModel is a MongoDB ORM for Ruby/Rails similar to ActiveRecord and DataMapper.}
15
15
  s.email = %q{sam@sampohlenz.com}
@@ -100,6 +100,10 @@ Gem::Specification.new do |s|
100
100
  "lib/mongomodel/support/types/symbol.rb",
101
101
  "lib/mongomodel/support/types/time.rb",
102
102
  "lib/mongomodel/version.rb",
103
+ "lib/rails/generators/mongo_model/config/config_generator.rb",
104
+ "lib/rails/generators/mongo_model/config/templates/mongomodel.yml",
105
+ "lib/rails/generators/mongo_model/model/model_generator.rb",
106
+ "lib/rails/generators/mongo_model/model/templates/model.rb",
103
107
  "mongomodel.gemspec",
104
108
  "spec/mongomodel/attributes/store_spec.rb",
105
109
  "spec/mongomodel/concerns/activemodel_spec.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongomodel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 7
10
- version: 0.2.7
9
+ - 8
10
+ version: 0.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Pohlenz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-05 00:00:00 +09:30
18
+ date: 2010-09-06 00:00:00 +09:30
19
19
  default_executable: console
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -173,6 +173,10 @@ files:
173
173
  - lib/mongomodel/support/types/symbol.rb
174
174
  - lib/mongomodel/support/types/time.rb
175
175
  - lib/mongomodel/version.rb
176
+ - lib/rails/generators/mongo_model/config/config_generator.rb
177
+ - lib/rails/generators/mongo_model/config/templates/mongomodel.yml
178
+ - lib/rails/generators/mongo_model/model/model_generator.rb
179
+ - lib/rails/generators/mongo_model/model/templates/model.rb
176
180
  - mongomodel.gemspec
177
181
  - spec/mongomodel/attributes/store_spec.rb
178
182
  - spec/mongomodel/concerns/activemodel_spec.rb