Class: Approvals::Writers::HashWriter

Inherits:
TextWriter
  • Object
show all
Defined in:
lib/approvals/writers/hash_writer.rb

Instance Method Summary collapse

Methods inherited from TextWriter

#extension, #write

Instance Method Details

#filter(data) ⇒ Object


13
14
15
16
# File 'lib/approvals/writers/hash_writer.rb', line 13

def filter data
  filter = ::Approvals::Filter.new(Approvals.configuration.excluded_json_keys)
  filter.apply(data)
end

#format(data) ⇒ Object


5
6
7
8
9
10
11
# File 'lib/approvals/writers/hash_writer.rb', line 5

def format(data)
  lines = filter(data).map do |key, value|
    "\t#{key.inspect} => #{value.inspect}"
  end.join("\n")

  "{\n#{lines}\n}\n"
end