Class: RFunk::ErrorChecking
- Inherits:
-
Object
- Object
- RFunk::ErrorChecking
- Defined in:
- lib/rfunk/attribute/error_checking.rb
Instance Method Summary collapse
- #raise_condition_error(type, value) ⇒ Object
- #raise_expected_attribute_type(name, value, types) ⇒ Object
- #raise_expected_parameter_type(name, value, types) ⇒ Object
- #raise_expected_return_type(name, value, types) ⇒ Object
- #raise_immutable(options, variable) ⇒ Object
- #raise_not_found(key, attributes) ⇒ Object
Instance Method Details
#raise_condition_error(type, value) ⇒ Object
3 4 5 |
# File 'lib/rfunk/attribute/error_checking.rb', line 3 def raise_condition_error(type, value) raise type, 'The condition was not met!' unless value end |
#raise_expected_attribute_type(name, value, types) ⇒ Object
11 12 13 |
# File 'lib/rfunk/attribute/error_checking.rb', line 11 def raise_expected_attribute_type(name, value, types) name, value, types, 'attribute' end |
#raise_expected_parameter_type(name, value, types) ⇒ Object
15 16 17 |
# File 'lib/rfunk/attribute/error_checking.rb', line 15 def raise_expected_parameter_type(name, value, types) name, value, types, 'parameter' end |
#raise_expected_return_type(name, value, types) ⇒ Object
7 8 9 |
# File 'lib/rfunk/attribute/error_checking.rb', line 7 def raise_expected_return_type(name, value, types) name, value, types, 'return' end |
#raise_immutable(options, variable) ⇒ Object
26 27 28 29 30 |
# File 'lib/rfunk/attribute/error_checking.rb', line 26 def raise_immutable(, variable) keys = .keys.select { |k| variable.key?(k) } = "Could not rebind a value '#{keys}', because they are immutable." raise RFunk::ImmutableError, if keys.any? end |
#raise_not_found(key, attributes) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rfunk/attribute/error_checking.rb', line 19 def raise_not_found(key, attributes) return if attributes.key?(key) = "Attribute with name '#{key}' does not exist. The only available attributes are '#{attributes.keys}'" raise RFunk::NotFoundError, end |