# File lib/hammer_cli/output/dsl.rb, line 5 def initialize(options={}) @current_path = options[:path] || [] end
# File lib/hammer_cli/output/dsl.rb, line 14 def build(&block) self.instance_eval &block end
# File lib/hammer_cli/output/dsl.rb, line 9 def fields @fields ||= [] @fields end
# File lib/hammer_cli/output/dsl.rb, line 45 def collection(key, label, options={}, &block) field key, label, Fields::Collection, options, &block end
# File lib/hammer_cli/output/dsl.rb, line 50 def current_path @current_path ||= [] @current_path end
# File lib/hammer_cli/output/dsl.rb, line 29 def custom_field(type, options={}, &block) self.fields << type.new(options, &block) end
# File lib/hammer_cli/output/dsl.rb, line 20 def field(key, label, type=nil, options={}, &block) options[:path] = current_path.clone options[:path] << key if !key.nil? options[:label] = label type ||= Fields::Field custom_field type, options, &block end
# File lib/hammer_cli/output/dsl.rb, line 39 def from(key) self.current_path.push key yield if block_given? self.current_path.pop end
# File lib/hammer_cli/output/dsl.rb, line 33 def label(label, options={}, &block) options[:path] = current_path.clone options[:label] = label custom_field Fields::Label, options, &block end