Module: Prototok::Utils::TypeAttributes
- Included in:
- Token
- Defined in:
- lib/prototok/utils/type_attributes.rb
Instance Method Summary collapse
Instance Method Details
#type(type, *attributes) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/prototok/utils/type_attributes.rb', line 4 def type type, *attributes unless type.is_a? Class Prototok.err(Errors::TypeMismatch, :type_expected, :type, Class, type) end attributes.each do |attrib| define_method "#{attrib}=" do |val| unless val.is_a? type Prototok.err(Errors::TypeMismatch, :type_expected, attrib, type, val) end super(val) end end end |