in_place_relation 0.0.2 → 0.1.0
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/lib/in_place_relation/version.rb +1 -1
- data/lib/in_place_relation.rb +6 -7
- metadata +3 -3
data/lib/in_place_relation.rb
CHANGED
@@ -9,9 +9,12 @@ require "in_place_relation/version"
|
|
9
9
|
#
|
10
10
|
# you can do this
|
11
11
|
# rel = SomeModel.where( ... ).in_place
|
12
|
-
# rel.joins
|
13
|
-
# rel.select
|
12
|
+
# rel.joins().where() if x
|
13
|
+
# rel.select() unless y
|
14
14
|
# rel.all
|
15
|
+
#
|
16
|
+
# and get original relation with:
|
17
|
+
# rel.relation # ActiveRecord::Relation
|
15
18
|
module InPlaceRelation
|
16
19
|
|
17
20
|
module Methods
|
@@ -25,14 +28,10 @@ module InPlaceRelation
|
|
25
28
|
|
26
29
|
attr_reader :relation
|
27
30
|
|
28
|
-
METHODS_TO_WRAP = ActiveRecord::Relation::ASSOCIATION_METHODS + ActiveRecord::Relation::MULTI_VALUE_METHODS + ActiveRecord::Relation::SINGLE_VALUE_METHODS
|
31
|
+
METHODS_TO_WRAP = ActiveRecord::Relation::ASSOCIATION_METHODS + ActiveRecord::Relation::MULTI_VALUE_METHODS + ActiveRecord::Relation::SINGLE_VALUE_METHODS + [:merge]
|
29
32
|
|
30
33
|
METHODS_TO_WRAP.each do |meth|
|
31
34
|
define_method( meth ) do |*args|
|
32
|
-
return @relation.send( meth, *args )
|
33
|
-
end
|
34
|
-
|
35
|
-
define_method( "#{meth}!" ) do |*args|
|
36
35
|
@relation = @relation.send( meth, *args )
|
37
36
|
return self
|
38
37
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Janukowicz/Starware
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-28 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|