ratatouille 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -163,7 +163,7 @@ Used to ensure that the list of keys exist in the Hash.
163
163
  Used to ensure given key exists in the Hash.
164
164
 
165
165
  * Eliminates the need to perform "given\_key" methods within a "required\_keys" block.
166
- * Block is optional
166
+ * Evaluates an optional block in context of key value (same as given\_key)
167
167
 
168
168
 
169
169
  #### Syntax
@@ -85,7 +85,7 @@ module Ratatouille
85
85
  #
86
86
  # @param [String,Symbol] req_key Required Key
87
87
  # @return [void]
88
- def required_key(req_key, &block)
88
+ def required_key(req_key, options={}, &block)
89
89
  if req_key.nil?
90
90
  validation_error("required_key needs key argument")
91
91
  return
@@ -101,7 +101,7 @@ module Ratatouille
101
101
  return
102
102
  end
103
103
 
104
- instance_eval(&block) if block_given?
104
+ given_key(req_key, options, &block) if block_given?
105
105
  rescue Exception => e
106
106
  validation_error("#{e.message}")
107
107
  end
@@ -1,4 +1,4 @@
1
1
  module Ratatouille
2
2
  # Gem Version
3
- VERSION = "1.2.4"
3
+ VERSION = "1.2.5"
4
4
  end
@@ -79,6 +79,14 @@ describe "Ratatouille::HashMethods" do
79
79
  end
80
80
  f.should be_false
81
81
  end
82
+
83
+ it "should change the scope name to default to the key if no name passed as option" do
84
+ n = ""
85
+ RatifierTest.new({:foo => "bar"}) do
86
+ required_key(:foo) { n = name }
87
+ end
88
+ n.should == ":foo"
89
+ end
82
90
  end
83
91
 
84
92
  describe "given_key" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratatouille
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 4
10
- version: 1.2.4
9
+ - 5
10
+ version: 1.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Johnson