husky 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/husky/data_source.rb +12 -11
- data/lib/husky/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9648310eaec6ddb1f227b88b3cc97925bba26808
|
4
|
+
data.tar.gz: 7a2163d91ca306a06cc6dd7912dc48a386469f01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8b5c4d81f2967bf9495541e606bc414ad1d5712ba98161bdf27a340569eb5a902580712eda8e1a9fb1038388414a3fbbb1374d7a5dadd8bb261d81bd5503eaf
|
7
|
+
data.tar.gz: dfbf5ec9b871cfaa06bd893d20c324f593bb7d2ae9a76fb2b9f4d1b48c95292227c07477ceeea9f9be85c2a25fbc2ec458b1b0f5f807474b0a67330336f9abfc
|
data/lib/husky/data_source.rb
CHANGED
@@ -12,7 +12,8 @@ module Husky
|
|
12
12
|
klass_id = "#{self.class.name.split('::')[1].downcase}_id".to_sym
|
13
13
|
repo = Husky::Repo::Registry.for(singular_association)
|
14
14
|
set = repo.all.select { |k,v| v.send(klass_id) == self.id }
|
15
|
-
|
15
|
+
receiving_class = repo.class.to_s[0..-5].split('::').reduce(Module, :const_get)
|
16
|
+
Husky::DataSource::MemoryRelation.new(set, self, receiving_class)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -38,27 +39,27 @@ module Husky
|
|
38
39
|
class MemoryRelation
|
39
40
|
include Enumerable
|
40
41
|
|
41
|
-
attr_reader :set, :caller, :
|
42
|
+
attr_reader :set, :caller, :receiving_class
|
42
43
|
|
43
|
-
def initialize(set, caller,
|
44
|
-
@set
|
45
|
-
@caller
|
46
|
-
@
|
44
|
+
def initialize(set, caller, receiving_class)
|
45
|
+
@set = set
|
46
|
+
@caller = caller
|
47
|
+
@receiving_class = receiving_class
|
47
48
|
end
|
48
49
|
|
49
50
|
def each
|
50
51
|
set.map { |item| yield item }
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def new(attributes)
|
55
|
+
receiving_class.new({ caller_id => caller.id })
|
56
|
+
end
|
56
57
|
|
57
58
|
def create(attributes)
|
58
|
-
|
59
|
+
receiving_class.create({ caller_id => caller.id })
|
59
60
|
end
|
60
61
|
|
61
|
-
def
|
62
|
+
def caller_id
|
62
63
|
"#{caller.class.to_s.split('::').last.downcase}_id".to_sym
|
63
64
|
end
|
64
65
|
|
data/lib/husky/version.rb
CHANGED