structure 0.25.0 → 0.25.1

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: 9d097be9799d796318524e7594f98050b1d41be8
4
- data.tar.gz: 710fa928be479806b678fc9c17ae3222d71f059b
3
+ metadata.gz: 12c6920942010f99e7c1e26fed12d0cd07d28788
4
+ data.tar.gz: 67f298813aa7f59d7e4e7c737363f82f6d4ac180
5
5
  SHA512:
6
- metadata.gz: 1c5f7f760400a8eb044df7efaa9a2d08ed8b0128db23659f64bbf4a98b9d2311f4772176a93c52c90745a0da4658aeba9cd85eaaf8719dfce2e3caa5b07973bf
7
- data.tar.gz: 1d1a43d8aac01183286e82832f38540b03f5a5d7c2f2487fefc5cf2ad422b03e433de0c7f0394663a06b0948b91dbafa2b0993a7f77e3cbe25ed9c9a92d0dd4b
6
+ metadata.gz: c90c4ad394683b5d8f4e425b0024b5ba2ef6d8664f76ba5e266987b91010ac0c6d18d8bc1f0c587c5b0a446ee9b076029d2e1e1ce9acef51872cae175cd25021
7
+ data.tar.gz: 1148c4a09f718b4441a1a3f8c4a072f4c1f4edd18dfec79676d9022874a41d2be4495cebe6d6ae4214733ba9fadc780212c92e46b05c6650a5676f351c41693a
data/lib/structure.rb CHANGED
@@ -34,6 +34,10 @@ module Structure
34
34
  module ClassMethods
35
35
  attr :value_names
36
36
 
37
+ def inherited(subclass)
38
+ subclass.instance_variable_set(:@value_names, value_names.dup)
39
+ end
40
+
37
41
  def value(name, &blk)
38
42
  define_method(name, &blk)
39
43
  @value_names << name
@@ -1,3 +1,3 @@
1
1
  module Structure
2
- VERSION = '0.25.0'
2
+ VERSION = '0.25.1'
3
3
  end
@@ -48,4 +48,13 @@ class StructureTest < MiniTest::Test
48
48
  assert_equal '#<Location latitude=10, longitude=100>', @location.inspect
49
49
  assert_equal @location.to_s, @location.inspect
50
50
  end
51
+
52
+ def test_subclasses
53
+ subclass = Class.new(Location) do
54
+ value(:name) { 'foo' }
55
+ end
56
+ obj = subclass.new(lat: 10, lng: 100)
57
+
58
+ assert_equal({ latitude: 10, longitude: 100, name: 'foo' }, obj.values)
59
+ end
51
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-11 00:00:00.000000000 Z
11
+ date: 2013-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest