Class: StrongType::MethodTypes
- Inherits:
-
Object
- Object
- StrongType::MethodTypes
- Defined in:
- lib/strong_ruby/strong_type/method_types.rb
Instance Attribute Summary collapse
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(*attrs) ⇒ MethodTypes
constructor
A new instance of MethodTypes.
- #validate!(*attrs) ⇒ Object
Constructor Details
#initialize(*attrs) ⇒ MethodTypes
Returns a new instance of MethodTypes.
5 6 7 |
# File 'lib/strong_ruby/strong_type/method_types.rb', line 5 def initialize(*attrs) @types = attrs end |
Instance Attribute Details
#types ⇒ Object (readonly)
Returns the value of attribute types.
3 4 5 |
# File 'lib/strong_ruby/strong_type/method_types.rb', line 3 def types @types end |
Instance Method Details
#validate!(*attrs) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/strong_ruby/strong_type/method_types.rb', line 9 def validate!(*attrs) type_check = types.each_with_index.map do |type, i| type === attrs[i] end.all? unless type_check raise StandardError.new("types are incorrect") end end |