class Naplug::Meta
Constants
- DEFAULT
- OPTIONS
Public Class Methods
new(meta = DEFAULT)
click to toggle source
# File lib/naplug/meta.rb, line 10 def initialize(meta = DEFAULT) validate meta @meta = DEFAULT.merge meta @meta[:benchmark] = Benchmark::Tms.new if @meta[:benchmark] end
Public Instance Methods
to_h()
click to toggle source
# File lib/naplug/meta.rb, line 25 def to_h @meta end
Private Instance Methods
validate(meta)
click to toggle source
# File lib/naplug/meta.rb, line 31 def validate(meta) invalid_options = meta.keys - OPTIONS raise Naplug::Error, "invalid meta option(s): #{invalid_options.join(', ')}" if invalid_options.any? # benchmark is allowed to be nil, false, true, or a Benchmark::Tms object case meta[:benchmark] when nil, true, false, Benchmark::Tms true else raise Naplug::Error, "invalid benchmark metadata: #{meta[:benchmark].class.to_s}" end end