leap 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,14 +18,19 @@ module Leap
18
18
  # The array of quorums defined within the committee.
19
19
  attr_reader :quorums
20
20
 
21
+ # An options hash
22
+ attr_reader :options
23
+
21
24
  # Creates a new <tt>Leap::Committee</tt> with the given name.
22
25
  #
23
26
  # Generally you don't create these objects directly; <tt>Leap::Decision#committee</tt> does that for you.
24
27
  #
25
28
  # @see Leap::Decision#committee
26
29
  # @param [Symbol] name The name of the committee, traditionally formulated to represent a computable attribute of the subject.
27
- def initialize(name)
30
+ # @param [Hash] options Any options you wish the committee to remember (for third-party use).
31
+ def initialize(name, options)
28
32
  @name = name
33
+ @options = options
29
34
  @quorums = []
30
35
  end
31
36
 
@@ -44,8 +44,9 @@ module Leap
44
44
  #
45
45
  # Used within a <tt>Leap::Subject#decide</tt> block to define a new committee. See <tt>Leap::Committee</tt> for details.
46
46
  # @param [Symbol] name The name of the attribute that the committee will return.
47
- def committee(name, &blk)
48
- committee = ::Leap::Committee.new(name)
47
+ # @param [Hash, optional] options Any options you wish the committee to remember (for third-party use).
48
+ def committee(name, options = {}, &blk)
49
+ committee = ::Leap::Committee.new(name, options)
49
50
  @committees << committee
50
51
  ::Blockenspiel.invoke blk, committee
51
52
  end
@@ -1,3 +1,3 @@
1
1
  module Leap
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -141,4 +141,20 @@ class TestLeap < Test::Unit::TestCase
141
141
  end
142
142
  end
143
143
  end
144
+
145
+ context 'A committee' do
146
+ setup do
147
+ class Owl
148
+ include Leap
149
+ decide :eye_size do
150
+ committee :eye_size, :measures => :length do
151
+ end
152
+ end
153
+ end
154
+ end
155
+
156
+ should 'remember options that it was given when it was created' do
157
+ assert_equal :length, Owl.decisions[:eye_size].committees.first.options[:measures]
158
+ end
159
+ end
144
160
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Rossmeissl
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-05-11 00:00:00 -04:00
20
+ date: 2011-05-25 00:00:00 -04:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency