Class: Fields::ContainerField

Inherits:
Field
  • Object
show all
Defined in:
lib/hammer_cli/output/fields.rb

Direct Known Subclasses

Collection, Label

Instance Attribute Summary

Attributes inherited from Field

#label, #parent, #path, #sets

Instance Method Summary collapse

Methods inherited from Field

#full_label, #hide_blank?, #hide_missing?, #id, #match_id?, #parameters

Constructor Details

#initialize(options = {}, &block) ⇒ ContainerField

Returns a new instance of ContainerField.



72
73
74
75
76
77
78
# File 'lib/hammer_cli/output/fields.rb', line 72

def initialize(options={}, &block)
  super(options)
  dsl = HammerCLI::Output::Dsl.new
  dsl.build(&block) if block_given?
  dsl.fields.each { |f| f.parent = self }
  self.output_definition.append dsl.fields
end

Instance Method Details

#display?(value) ⇒ Boolean

Returns:



89
90
91
92
93
94
95
96
97
# File 'lib/hammer_cli/output/fields.rb', line 89

def display?(value)
  if value.is_a?(HammerCLI::Output::DataMissing)
    !hide_missing?
  elsif value.nil? || value.empty?
    !hide_blank?
  else
    true
  end
end

#fieldsObject



85
86
87
# File 'lib/hammer_cli/output/fields.rb', line 85

def fields
  @output_definition.fields
end

#output_definitionObject



80
81
82
83
# File 'lib/hammer_cli/output/fields.rb', line 80

def output_definition
  @output_definition ||= HammerCLI::Output::Definition.new
  @output_definition
end