Class: ErrorBuilder::FormatResolver
- Inherits:
-
Object
- Object
- ErrorBuilder::FormatResolver
- Defined in:
- lib/error_builder/format_resolver.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
- #built_in_formatter ⇒ Object
- #formatter ⇒ Object
-
#initialize(format) ⇒ FormatResolver
constructor
A new instance of FormatResolver.
Constructor Details
#initialize(format) ⇒ FormatResolver
Returns a new instance of FormatResolver.
7 8 9 |
# File 'lib/error_builder/format_resolver.rb', line 7 def initialize(format) @format = format end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/error_builder/format_resolver.rb', line 5 def format @format end |
Instance Method Details
#built_in_formatter ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/error_builder/format_resolver.rb', line 17 def built_in_formatter case format when :array Formats::Array when :hash Formats::Hash else raise ArgumentError, "Unsupported format: #{format}" end end |
#formatter ⇒ Object
11 12 13 14 15 |
# File 'lib/error_builder/format_resolver.rb', line 11 def formatter return built_in_formatter unless format.is_a?(Class) format end |