class Mumukit::Sync::Store::Base

Public Instance Methods

read_resource(sync_key) click to toggle source
# File lib/mumukit/sync/store/base.rb, line 2
def read_resource(sync_key)
  transform_after_symbolize sync_key.kind, transform_before_symbolize(sync_key.kind, do_read(sync_key)).deep_symbolize_keys
end

Private Instance Methods

transform_after_symbolize(_key, json) click to toggle source
# File lib/mumukit/sync/store/base.rb, line 15
def transform_after_symbolize(_key, json)
  json
end
transform_before_symbolize(key, json) click to toggle source

We are assuming rails-like models, that can be whitelisted, and that resource-hashes resemble the model structure. The store must ensure that only valid hashes are read

# File lib/mumukit/sync/store/base.rb, line 11
def transform_before_symbolize(key, json)
  key.as_module.whitelist_attributes(json, relations: true)
end