Class: Super::Display::SchemaTypes::Badge
- Inherits:
-
Object
- Object
- Super::Display::SchemaTypes::Badge
- Extended by:
- Useful::Builder
- Defined in:
- lib/super/display/schema_types.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(builder) ⇒ Badge
constructor
A new instance of Badge.
Methods included from Useful::Builder
Constructor Details
#initialize(builder) ⇒ Badge
Returns a new instance of Badge.
67 68 69 70 71 72 |
# File 'lib/super/display/schema_types.rb', line 67 def initialize(builder) @builder = builder @whens = {} format_for_lookup(&:itself) format_for_display(&:itself) end |
Instance Method Details
#build ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/super/display/schema_types.rb', line 92 def build @builder.transform do |value| lookup_value = @format_for_lookup.call(value) block = @whens[lookup_value] || @else Super::Badge.new( @format_for_display.call(value), styles: block&.call ) end @builder.build end |