Class: Batali::UnitDependency

Inherits:
Grimoire::DEPENDENCY_CLASS
  • Object
show all
Defined in:
lib/batali/monkey.rb

Overview

Custom named unit dependency

Instance Method Summary collapse

Instance Method Details

#to_json(*args) ⇒ Object

Override to properly convert to JSON



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/batali/monkey.rb', line 13

def to_json(*args)
  result = [
    name,
    *requirement.requirements.map do |req|
      req.join(' ')
    end
  ]
  # Prevent stupid conversion errors of
  # JSON::Ext::Generator::State into Hash
  args.map!{|v| v.respond_to?(:to_h) ? v.to_h : v}
  MultiJson.dump(result, *args)
end