bsm-models 0.5.6 → 0.6.3
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.
|
@@ -4,7 +4,7 @@ module Bsm::Model::EagerDescendants
|
|
|
4
4
|
module ClassMethods
|
|
5
5
|
|
|
6
6
|
def descendants
|
|
7
|
-
eager_constantize!
|
|
7
|
+
eager_constantize!
|
|
8
8
|
super
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -22,5 +22,5 @@ module Bsm::Model::EagerDescendants
|
|
|
22
22
|
@__eagerly_constantized__ = true
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
end
|
|
25
|
+
end unless Rails.application.config.respond_to?(:eager_load) && Rails.application.config.eager_load
|
|
26
26
|
end
|
|
@@ -6,7 +6,7 @@ module Bsm::Model::HasManySerialized
|
|
|
6
6
|
module ClassMethods
|
|
7
7
|
|
|
8
8
|
def has_many_serialized(name, options = {})
|
|
9
|
-
Builder.build(self, name.to_sym, options)
|
|
9
|
+
ActiveRecord::VERSION::STRING < '4.0.0' ? Builder.build(self, name.to_sym, options) : Builder.build(self, name.to_sym, options, {})
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
end
|
|
@@ -10,6 +10,15 @@ module Bsm::Model::StiConvertable
|
|
|
10
10
|
METHOD
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
def self.scoping(*)
|
|
14
|
+
yield
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# AR <4.0 compatibility
|
|
18
|
+
def self.scoping(klass, current_scope, &block)
|
|
19
|
+
klass.send(:with_scope, current_scope, &block)
|
|
20
|
+
end if ActiveRecord::VERSION::MAJOR < 4
|
|
21
|
+
|
|
13
22
|
module ClassMethods
|
|
14
23
|
|
|
15
24
|
# @Override: Allow to specify a kind
|
|
@@ -20,9 +29,7 @@ module Bsm::Model::StiConvertable
|
|
|
20
29
|
klass = real_descendants.find {|k| k.kind == kind } || fallback_descendant
|
|
21
30
|
return super if klass == self
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
klass.new(attributes, *args, &block)
|
|
25
|
-
end
|
|
32
|
+
Bsm::Model::StiConvertable.scoping(klass, current_scope) { klass.new(attributes, *args, &block) }
|
|
26
33
|
end
|
|
27
34
|
|
|
28
35
|
def real_descendants
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bsm-models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: abstract
|
|
@@ -76,7 +76,7 @@ dependencies:
|
|
|
76
76
|
- !ruby/object:Gem::Version
|
|
77
77
|
version: '0'
|
|
78
78
|
- !ruby/object:Gem::Dependency
|
|
79
|
-
name: sqlite3
|
|
79
|
+
name: sqlite3
|
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
|
81
81
|
none: false
|
|
82
82
|
requirements:
|