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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a932c0080a04342cc7d744d1bf4d8d57db79a3b2
4
- data.tar.gz: 7e66a4560393b343c5ff6efdbd4cada2356bd1ab
3
+ metadata.gz: 9648310eaec6ddb1f227b88b3cc97925bba26808
4
+ data.tar.gz: 7a2163d91ca306a06cc6dd7912dc48a386469f01
5
5
  SHA512:
6
- metadata.gz: ebb438dbe4cf698dd92d95fae21ff9cc2bb81ff770548a67c175d32477a314931f6f417616c7da49b80cd6759ff9149efe805d2e0650a95e2ffc3c4c020d16b8
7
- data.tar.gz: d2d55670b24717e6db577de9565089806630580a67448eb4a8e82e0d1286feef8abafb2c003995ab7aec649d67c050c4103d364183d19d655764482bfc9a2714
6
+ metadata.gz: c8b5c4d81f2967bf9495541e606bc414ad1d5712ba98161bdf27a340569eb5a902580712eda8e1a9fb1038388414a3fbbb1374d7a5dadd8bb261d81bd5503eaf
7
+ data.tar.gz: dfbf5ec9b871cfaa06bd893d20c324f593bb7d2ae9a76fb2b9f4d1b48c95292227c07477ceeea9f9be85c2a25fbc2ec458b1b0f5f807474b0a67330336f9abfc
@@ -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
- Husky::DataSource::MemoryRelation.new(set, self, repo)
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, :receiver
42
+ attr_reader :set, :caller, :receiving_class
42
43
 
43
- def initialize(set, caller, receiver)
44
- @set = set
45
- @caller = caller
46
- @receiver = receiver
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
- # def new(attributes)
54
- # receiver.new({ receiver_id => caller.id })
55
- # end
54
+ def new(attributes)
55
+ receiving_class.new({ caller_id => caller.id })
56
+ end
56
57
 
57
58
  def create(attributes)
58
- receiver.create({ receiver_id => caller.id })
59
+ receiving_class.create({ caller_id => caller.id })
59
60
  end
60
61
 
61
- def receiver_id
62
+ def caller_id
62
63
  "#{caller.class.to_s.split('::').last.downcase}_id".to_sym
63
64
  end
64
65
 
@@ -1,3 +1,3 @@
1
1
  module Husky
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: husky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Fiser