Class: Slack::BlockKit::TypeRestrictedArray
- Inherits:
-
Array
- Object
- Array
- Slack::BlockKit::TypeRestrictedArray
- Defined in:
- lib/slack/block_kit/type_restricted_array.rb
Instance Method Summary collapse
- #<<(item) ⇒ Object
-
#initialize(*classes) ⇒ TypeRestrictedArray
constructor
A new instance of TypeRestrictedArray.
Constructor Details
#initialize(*classes) ⇒ TypeRestrictedArray
Returns a new instance of TypeRestrictedArray.
8 9 10 |
# File 'lib/slack/block_kit/type_restricted_array.rb', line 8 def initialize(*classes) @classes = classes end |
Instance Method Details
#<<(item) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/slack/block_kit/type_restricted_array.rb', line 12 def <<(item) unless @classes.any? { |cls| item.is_a?(cls) } raise TypeError, "#{self.class} only accepts #{@classes}" end super(item) end |