kartograph 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kartograph/property.rb +6 -2
- data/lib/kartograph/version.rb +1 -1
- data/spec/lib/kartograph/property_spec.rb +16 -0
- 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: 71c910042ed1e28e5925d425cb66668cbd07f415
|
4
|
+
data.tar.gz: 89dbd0a363a63fad5d4100cffa9b6a088ba01b6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5225b1657956962dd98cfd4274f7903fbad3c5bc41a56cb5a6a870b20281d7a596abba9879ca1b9633d2dd2267ffe306cbdfb514c7b630ecb8a9d2cfb1282b
|
7
|
+
data.tar.gz: fd9fe190754dae7eadb06aad30f4092deafbca8f570035ee4f5d4dc9f0935a986eeca7ff66905a00280b172c140dee2f4d5205a971fe5016bfd8404d396b4ab8
|
data/lib/kartograph/property.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Kartograph
|
2
2
|
class Property
|
3
|
-
attr_reader :name, :options
|
4
|
-
attr_accessor :map
|
3
|
+
attr_reader :name, :options, :map
|
5
4
|
|
6
5
|
def initialize(name, options = {}, &block)
|
7
6
|
@name = name
|
@@ -26,6 +25,11 @@ module Kartograph
|
|
26
25
|
@key
|
27
26
|
end
|
28
27
|
|
28
|
+
def map=(map)
|
29
|
+
@map = map
|
30
|
+
@artist = Artist.new(@map)
|
31
|
+
end
|
32
|
+
|
29
33
|
def value_for(object, scope = nil)
|
30
34
|
value = object.send(name)
|
31
35
|
return if value.nil?
|
data/lib/kartograph/version.rb
CHANGED
@@ -231,5 +231,21 @@ describe Kartograph::Property do
|
|
231
231
|
expect(duped.options).to_not be(instance.options)
|
232
232
|
expect(duped.options).to eq(instance.options)
|
233
233
|
end
|
234
|
+
|
235
|
+
context 'setting the map after duping' do
|
236
|
+
it 'draws a value' do
|
237
|
+
# NOTE: This test is a regression test introduced by caching of Artist instance.
|
238
|
+
dummy_class = Struct.new(:id, :name)
|
239
|
+
dummy = dummy_class.new
|
240
|
+
dummy.id = 123
|
241
|
+
|
242
|
+
instance = Kartograph::Property.new(:id, scopes: [:read])
|
243
|
+
duped = instance.dup
|
244
|
+
duped.map = Kartograph::Map.new
|
245
|
+
val = duped.value_for(dummy)
|
246
|
+
|
247
|
+
expect(val).to_not be_nil
|
248
|
+
end
|
249
|
+
end
|
234
250
|
end
|
235
251
|
end
|