module Skalka::Functions

Constants

EXTRA_FIELDS
MAIN_FIELDS

Public Instance Methods

extra_fields(parsed_json) click to toggle source
# File lib/skalka/functions.rb, line 24
def extra_fields(parsed_json)
  parsed_json.slice(*EXTRA_FIELDS)
end
extract_resource(parsed_json) click to toggle source
# File lib/skalka/functions.rb, line 28
def extract_resource(parsed_json)
  included = parsed_json.fetch(:included, [])

  (
    self[:fetch_data] >>
    self[:map_or_pass][ Resource[:build].with(included) ]
  ).call(parsed_json)
end
fetch_data(item) click to toggle source
# File lib/skalka/functions.rb, line 20
def fetch_data(item)
  item.fetch(:data, {})
end
map_or_pass(func) click to toggle source
# File lib/skalka/functions.rb, line 37
def map_or_pass(func)
  self[:is, Array, self[:map_array, func]] >> self[:is, Hash, func]
end
parse_and_symbolize_keys(json) click to toggle source
# File lib/skalka/functions.rb, line 41
def parse_and_symbolize_keys(json)
  (self[:parse_json] >> self[:deep_symbolize_keys]).call(json)
end
pick_main_attributes(item) click to toggle source
# File lib/skalka/functions.rb, line 45
def pick_main_attributes(item)
  item.slice(*MAIN_FIELDS)
end