Method: MarkdownRecord::ModelInflator#json

Defined in:
lib/markdown_record/models/model_inflator.rb

#json(filters, subdirectory) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/markdown_record/models/model_inflator.rb', line 31

def json(filters, subdirectory)
  path = json_path(filters, subdirectory)
  json_hash = json_source(path)
  
  json_hash.delete(::MarkdownRecord::ContentFragment.json_klass) if filters.delete(:exclude_fragments)
  json_hash = filters[:klass].present? ? json_hash[filters.delete(:klass).json_klass] : json_hash.values.flatten
  json_hash ||= []
  json_hash
end