Class: Graphiti::OpenAPI::Source

Inherits:
Struct
  • Object
show all
Defined in:
app/models/graphiti/open_api/source.rb

Constant Summary collapse

DEFAULT_REWRITE =
-> (text) { text }
DEFAULT_PARSE =
JSON.method(:parse)
DEFAULT_PROCESS =
Functions[:deep_symbolize_keys]

Class Method Summary collapse

Class Method Details

.load(path, name: path.basename, rewrite: DEFAULT_REWRITE, process: DEFAULT_PROCESS, parse: DEFAULT_PARSE) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/graphiti/open_api/source.rb', line 15

def self.load(path, name: path.basename, rewrite: DEFAULT_REWRITE, process: DEFAULT_PROCESS, parse: DEFAULT_PARSE)
  text = rewrite.(path.read)
  parsed = parse.(text)
  data = process.(parsed)

  new(
    name: name,
    path: path,
    data: data,
  )
end