Class: Ritsu::Utility::CheckUponAddSet
- Inherits:
-
Set
- Object
- Set
- Ritsu::Utility::CheckUponAddSet
- Defined in:
- lib/ritsu/utility/check_upon_add_set.rb
Instance Method Summary collapse
- #<<(x) ⇒ Object
- #add(x) ⇒ Object
- #add?(x) ⇒ Boolean
-
#initialize(*args, &block) ⇒ CheckUponAddSet
constructor
A new instance of CheckUponAddSet.
Constructor Details
#initialize(*args, &block) ⇒ CheckUponAddSet
Returns a new instance of CheckUponAddSet.
6 7 8 9 10 11 12 13 |
# File 'lib/ritsu/utility/check_upon_add_set.rb', line 6 def initialize(*args, &block) if block_given? @check_block = block else @check_block = Proc.new { } end super(*args) end |
Instance Method Details
#<<(x) ⇒ Object
15 16 17 18 |
# File 'lib/ritsu/utility/check_upon_add_set.rb', line 15 def <<(x) @check_block.call(self, x) super(x) end |
#add(x) ⇒ Object
20 21 22 23 |
# File 'lib/ritsu/utility/check_upon_add_set.rb', line 20 def add(x) @check_block.call(self, x) super(x) end |
#add?(x) ⇒ Boolean
25 26 27 28 29 30 31 32 |
# File 'lib/ritsu/utility/check_upon_add_set.rb', line 25 def add?(x) begin @check_block.call(self, x) super(x) rescue nil end end |