jimmy 0.4.6 → 0.4.7

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: 390e7947ce86632067be15b72c4b5ba5f2c4173e
4
- data.tar.gz: 6a0ab25b1dcb989e0134aa3c1c65cca1c20de984
3
+ metadata.gz: 34798f1a348146e90f429b56679534c18b4abd0b
4
+ data.tar.gz: 573d2b3df49c893a637e59add2c6072d8594abb0
5
5
  SHA512:
6
- metadata.gz: 76b2bc0690eb1ea1efacec551d84a9ac5f36f4649f9492036f82a1d3b07b4dcb4cdb4fe667d61253f37c9ec5f616bff96ecda9dc9c87617b7ce72407586facb7
7
- data.tar.gz: c88a9274de459bafca324b0ddb451d10dac429e3613f7745466d291ec83de34c54f781ca62945fd42c44b3bb0aa3e34dac560a8e18c8fc56b33958fd06474f32
6
+ metadata.gz: e84ef0ceaa4662559bfac862e456430e3b70cc6eb3fec016d4952b8fb99177795bd0eefa9f349cba509231d828ca50ff4a73523c678fa7467792be3f9180ff90
7
+ data.tar.gz: 9990a5a746d8ad34114832f4d5d83aa7fb42996eb3842a26cba58f789b2e0747b77ed5c8325c659c1452742eb12796d31705b39760b16c92f591a84abbafd50e
@@ -1,23 +1,27 @@
1
1
  module Jimmy
2
2
  class Reference
3
- attr_reader :uri
3
+ include SchemaCreation::MetadataMethods
4
+ attr_reader :uri, :data
4
5
 
5
- def initialize(uri, nullable = false)
6
+ def initialize(uri, nullable = false, *args, **opts, &block)
6
7
  @uri = uri
7
8
  @nullable = nullable
9
+ @data = {}
10
+ args.each { |arg| __send__ arg }
11
+ opts.each { |arg| __send__ *arg }
12
+ instance_exec &block if block
8
13
  end
9
14
 
10
15
  def compile
11
- if nullable?
16
+ data.merge(nullable? ?
12
17
  {
13
18
  'anyOf' => [
14
19
  {'type' => 'null'},
15
20
  ref_hash
16
21
  ]
17
- }
18
- else
22
+ } :
19
23
  ref_hash
20
- end
24
+ )
21
25
  end
22
26
 
23
27
  def nullable?
@@ -32,7 +32,7 @@ module Jimmy
32
32
  module Referencing
33
33
  def method_missing(name, *args, &block)
34
34
  if schema.definitions[name]
35
- ref *args, definition(name)
35
+ ref *args, definition(name), &block
36
36
  else
37
37
  super
38
38
  end
@@ -46,9 +46,9 @@ module Jimmy
46
46
  "/#{schema.name}#/definitions/#{id}"
47
47
  end
48
48
 
49
- def ref(*args, uri)
49
+ def ref(*args, uri, &block)
50
50
  handler = SchemaCreation.handlers[self.class]
51
- instance_exec(Reference.new(uri), *args, &handler) if handler
51
+ instance_exec(Reference.new(uri, &block), *args, &handler) if handler
52
52
  end
53
53
  end
54
54
 
data/lib/jimmy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jimmy
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jimmy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil E. Pearson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema