detailed 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/lib/detailed.rb +11 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28e43c195327231d8e2e93365dff966ebdbc98ef
|
4
|
+
data.tar.gz: 53854de1aef853ca8085cabd40afc707b2ff9c13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3247784accccc96c5465a21a0241fb46f102cc54f9b1485b332eee0d16fb6d67580a334f2f36b993add05ffdaaba66db0f7ea32e3fdb45f3c7cbf38e0cda11c9
|
7
|
+
data.tar.gz: 4f78a226d723cc07c99b9df0f2f3f8dfa1f46fc75ecac79f94f6b9df1b57616760d92bc2adc9cbd4a4e887f561f45ea2f7dbf1ca59a71ff03febc7bfff143ea3
|
data/lib/detailed.rb
CHANGED
@@ -16,23 +16,23 @@ module Detailed
|
|
16
16
|
|
17
17
|
def all_with_details
|
18
18
|
@subclasses ||= []
|
19
|
-
@subclasses.inject(self.
|
19
|
+
@subclasses.inject(self.unscoped) { |a,b| a.includes(:"details_of_#{b.name.tableize}") }
|
20
20
|
end
|
21
21
|
|
22
22
|
def request_details
|
23
23
|
self.superclass.add_subclass(self)
|
24
24
|
|
25
25
|
class_eval do
|
26
|
-
#has_one :details, class_name: "#{self.superclass.name}#{self.name}Detail", dependent: :destroy
|
27
26
|
accepts_nested_attributes_for :"details_of_#{self.name.tableize}"
|
28
|
-
|
29
|
-
|
27
|
+
default_scope do
|
28
|
+
eager_load :"details_of_#{self.name.tableize}"
|
29
|
+
end
|
30
30
|
|
31
31
|
alias :details :"details_of_#{self.name.tableize}"
|
32
32
|
alias :details= :"details_of_#{self.name.tableize}="
|
33
33
|
|
34
34
|
after_initialize do
|
35
|
-
self.details ||=
|
35
|
+
self.details ||= "#{self.class.superclass.name}#{self.class.name}Detail".constantize.new if self.new_record?
|
36
36
|
end
|
37
37
|
|
38
38
|
alias :__old_method_missing :method_missing
|
@@ -59,14 +59,14 @@ module Detailed
|
|
59
59
|
raise e
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def method_missing a, *b
|
64
64
|
__old_method_missing a, *b
|
65
65
|
rescue NoMethodError, NameError => e
|
66
66
|
begin
|
67
67
|
details.send a, *b
|
68
68
|
rescue NoMethodError, NameError
|
69
|
-
|
69
|
+
raise e
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -85,15 +85,13 @@ module Detailed
|
|
85
85
|
module AssociationScope
|
86
86
|
def self.included cl
|
87
87
|
cl.class_eval do
|
88
|
-
def maybe_split(table, field, reflection
|
88
|
+
def maybe_split(table, field, reflection)
|
89
89
|
if field.match /\./
|
90
90
|
table, field = field.split(/\./, 2)
|
91
91
|
table = alias_tracker.aliased_table_for(table, table_alias_for(reflection, self.reflection != reflection))
|
92
|
-
|
93
|
-
#scope = scope.merge()
|
94
92
|
end
|
95
93
|
|
96
|
-
[table, field
|
94
|
+
[table, field]
|
97
95
|
end
|
98
96
|
|
99
97
|
# Extend add_constraints support for "table.column" notation
|
@@ -132,8 +130,8 @@ module Detailed
|
|
132
130
|
end
|
133
131
|
|
134
132
|
# this is our addition
|
135
|
-
table, key
|
136
|
-
foreign_table, foreign_key
|
133
|
+
table, key = maybe_split(table, key, reflection)
|
134
|
+
foreign_table, foreign_key = maybe_split(foreign_table, foreign_key, reflection)
|
137
135
|
# end
|
138
136
|
|
139
137
|
if reflection == chain.last
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: detailed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Łabanowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An ActiveRecord module giving you the power of multiple table inheritance
|
14
14
|
while still resorting to an API resembling single table inheritance
|