active_mongo 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/active_mongo.gemspec +1 -1
- data/lib/active_mongo.rb +17 -5
- data/lib/active_mongo_collection.rb +5 -8
- data/lib/active_mongo_instance.rb +3 -7
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/active_mongo.gemspec
CHANGED
data/lib/active_mongo.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'mongo'
|
2
|
-
require '
|
2
|
+
require 'active_mongo_uniquenesss'
|
3
3
|
include Mongo
|
4
4
|
|
5
5
|
config = YAML::load(File.open("#{RAILS_ROOT}/config/mongo.yml"))[Rails.env]
|
@@ -7,7 +7,7 @@ config = YAML::load(File.open("#{RAILS_ROOT}/config/mongo.yml"))[Rails.env]
|
|
7
7
|
$mongo_conn = Connection.new(config["host"], config["port"], :pool_size => 5, :timeout => 5)
|
8
8
|
$mongo_db = $mongo_conn.db(config["database"])
|
9
9
|
|
10
|
-
require '
|
10
|
+
require 'active_mongo_has_many'
|
11
11
|
|
12
12
|
module ActiveMongo
|
13
13
|
|
@@ -18,10 +18,22 @@ module ActiveMongo
|
|
18
18
|
include ActiveMongo::HasMany::InstanceMethods
|
19
19
|
|
20
20
|
class << self; attr_accessor :scope; end
|
21
|
+
|
22
|
+
def self.extended(klass)
|
23
|
+
class << klass
|
24
|
+
alias __old_name name
|
25
|
+
def name(*args, &blk)
|
26
|
+
return @name || self.__old_name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
self.extended(self)
|
32
|
+
|
21
33
|
end
|
22
34
|
end
|
23
35
|
|
24
36
|
|
25
|
-
require '
|
26
|
-
require '
|
27
|
-
require '
|
37
|
+
require 'active_mongo_collection'
|
38
|
+
require 'active_mongo_instance'
|
39
|
+
require 'active_mongo_scope'
|
@@ -53,9 +53,6 @@ ActiveMongo::Base.class_eval do
|
|
53
53
|
def self.extended(klass)
|
54
54
|
class << klass
|
55
55
|
alias __old_new new
|
56
|
-
def new(*args, &blk)
|
57
|
-
__old_new(*args, &blk).freeze
|
58
|
-
end
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
@@ -64,11 +61,11 @@ ActiveMongo::Base.class_eval do
|
|
64
61
|
def self.new(*attrs)
|
65
62
|
attrs = attrs[0]
|
66
63
|
|
67
|
-
if self.scope
|
68
|
-
|
69
|
-
|
70
|
-
end
|
64
|
+
# if self.scope
|
65
|
+
# attrs ||= {}
|
66
|
+
# attrs.merge!(self.scope)
|
67
|
+
# end
|
71
68
|
|
72
|
-
eval(self.name || @name).__old_new(attrs)
|
69
|
+
eval(self.name || @name).__old_new(attrs, :scope => self.scope)
|
73
70
|
end
|
74
71
|
end
|
@@ -4,15 +4,11 @@ ActiveMongo::Base.class_eval do
|
|
4
4
|
|
5
5
|
attrs = attr[0] || {}
|
6
6
|
|
7
|
-
self.class.attr_accessible_get.each do |field|
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
7
|
if self.class.attr_accessible_get.any?
|
12
|
-
attrs.delete_if {|
|
8
|
+
attrs.delete_if {|key, value| !self.class.attr_accessible_get.include?(key.to_sym) }
|
13
9
|
end
|
14
10
|
|
15
|
-
attrs.merge!(
|
11
|
+
attrs.merge!(attr[1][:scope]) if attr[1] && attr[1][:scope]
|
16
12
|
|
17
13
|
attrs.each do |key, value|
|
18
14
|
self.set_var(key, value)
|
@@ -69,7 +65,7 @@ ActiveMongo::Base.class_eval do
|
|
69
65
|
def update_attributes(*attrs)
|
70
66
|
attrs = attrs[0]
|
71
67
|
if self.class.attr_accessible_get.any?
|
72
|
-
attrs.delete_if {|
|
68
|
+
attrs.delete_if {|key, value| !self.class.attr_accessible_get.include?(key.to_sym) }
|
73
69
|
end
|
74
70
|
|
75
71
|
attrs.each do |key, value|
|