Module: Pliny::CanonicalLogLineHelpers::ClassMethods

Defined in:
lib/pliny/canonical_log_line_helpers.rb

Instance Method Summary collapse

Instance Method Details

#log_field(name, type) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pliny/canonical_log_line_helpers.rb', line 7

def log_field(name, type)
  unless name.is_a?(Symbol)
    raise ArgumentError, "Expected first argument to be a symbol"
  end

  @fields ||= {}
  @fields[name] = type
  define_method(:"#{name}=") do |val|
    set_field(name, val)
  end
end