Class: LcpRuby::Dsl::SummaryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/dsl/presenter_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeSummaryBuilder

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:, **options)
  f = { "field" => name.to_s, "function" => function.to_s }
  f["label"] = options[:label] if options[:label]
  f["renderer"] = options[:renderer].to_s if options[:renderer]
  f["options"] = HashUtils.stringify_deep(options[:options]) if options[:options]
  @fields << f
end

#to_hashObject



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