module Lacerda
Represents a DataStructure AST member and helps transforming it into a json schema.
This represents a description of an Object (as it was in MSON and later JSON Schema). It can come in two flavors:
1) A published object 2) A consumed object
A published object only refers to one servce:
- its publisher
However, a consumed object is referring to two services:
- its publisher - its consumer
This is so you can write your own reporters
Constants
- SCOPE_SEPARATOR
- VERSION
Public Class Methods
deep_copy(object)
click to toggle source
Poor man's deep copy: json 🆗 🆒
# File lib/lacerda.rb, line 31 def self.deep_copy(object) JSON.parse({m: object}.to_json)['m'] end
underscore(string)
click to toggle source
- An underscore that doesn't turn
-
into /
# File lib/lacerda.rb, line 24 def self.underscore(string) string.gsub(/#{SCOPE_SEPARATOR}/, ':') .underscore .gsub(/:/, SCOPE_SEPARATOR) end
validate_reporter(reporter)
click to toggle source
# File lib/lacerda.rb, line 16 def self.validate_reporter(reporter) return Lacerda::Reporters::MultiReporter.new(reporter) if reporter.is_a?(Array) return reporter unless reporter return reporter if reporter.class <= Lacerda::Reporter raise "reporter must inherit from Lacerda::Reporter, but #{reporter.class.name} doesn't" end