Class: Contracts::ErrorFormatters
- Inherits:
-
Object
- Object
- Contracts::ErrorFormatters
- Defined in:
- lib/contracts/error_formatter.rb
Class Method Summary collapse
- .class_for(data) ⇒ Object
-
.failure_msg(data) ⇒ Object
# Given a hash, prints out a failure message.
- .keyword_args?(data) ⇒ Boolean
Class Method Details
.class_for(data) ⇒ Object
10 11 12 13 |
# File 'lib/contracts/error_formatter.rb', line 10 def self.class_for(data) return Contracts::KeywordArgsErrorFormatter if keyword_args?(data) DefaultErrorFormatter end |
.failure_msg(data) ⇒ Object
# Given a hash, prints out a failure message. # This function is used by the default #failure_callback method # and uses the hash passed into the failure_callback method.
6 7 8 |
# File 'lib/contracts/error_formatter.rb', line 6 def self.failure_msg(data) class_for(data).new(data). end |
.keyword_args?(data) ⇒ Boolean
15 16 17 |
# File 'lib/contracts/error_formatter.rb', line 15 def self.keyword_args?(data) data[:contract].is_a?(Contracts::Builtin::KeywordArgs) && data[:arg].is_a?(Hash) end |