Class: LcpRuby::Dsl::SummaryBuilder
- Inherits:
-
Object
- Object
- LcpRuby::Dsl::SummaryBuilder
- Defined in:
- lib/lcp_ruby/dsl/presenter_builder.rb
Instance Method Summary collapse
- #enabled(value = true) ⇒ Object
- #field(name, function:, **options) ⇒ Object
-
#initialize ⇒ SummaryBuilder
constructor
A new instance of SummaryBuilder.
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ SummaryBuilder
Returns a new instance of SummaryBuilder.
707 708 709 710 |
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 707 def initialize @enabled_value = true @fields = [] end |
Instance Method Details
#enabled(value = true) ⇒ Object
712 713 714 |
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 712 def enabled(value = true) @enabled_value = value end |
#field(name, function:, **options) ⇒ Object
716 717 718 719 720 721 722 |
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 716 def field(name, function:, **) f = { "field" => name.to_s, "function" => function.to_s } f["label"] = [:label] if [:label] f["renderer"] = [:renderer].to_s if [:renderer] f["options"] = HashUtils.stringify_deep([:options]) if [:options] @fields << f end |
#to_hash ⇒ Object
724 725 726 727 728 |
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 724 def to_hash hash = { "enabled" => @enabled_value } hash["fields"] = @fields unless @fields.empty? hash end |