unpolymorph 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 TODO: Write your name
1
+ Copyright (c) 2013 Marek Janukowicz
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/unpolymorph.rb CHANGED
@@ -29,7 +29,9 @@ module Unpolymorph
29
29
 
30
30
  define_method( "#{name}=" ) do |value|
31
31
  associations.each do |assoc|
32
- if value.class.base_class.to_s.underscore == assoc.to_s
32
+ # TODO: Doing reflect... every time is suboptimal
33
+ assoc_ref = self.class.reflect_on_association( assoc.to_sym )
34
+ if value.class.base_class == assoc_ref.klass
33
35
  send( "#{assoc}=", value )
34
36
  instance_variable_set( "@_unpolymorph_#{name}", value )
35
37
  return
@@ -1,3 +1,3 @@
1
1
  module Unpolymorph
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unpolymorph
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marek Janukowicz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-07-19 00:00:00 +02:00
18
+ date: 2014-04-02 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21