Sha256: 97d9ae6bf9288b874d7bce383d941d25a8c75638f47a3c31f0f9bdc5b6950922
Contents?: true
Size: 488 Bytes
Versions: 5
Compression:
Stored size: 488 Bytes
Contents
require 'multi_json' module Diesel class DataModel attr_reader :definition def initialize(definition) @definition = definition end def build(parameter_name, env) context = env[:context] h = context.get_attribute(parameter_name) return nil unless h json = definition.properties.reduce({}) do |m, (name, property)| name = name.to_sym m[name] = h[name] if h[name]; m end MultiJson.dump(json) end end end
Version data entries
5 entries across 5 versions & 1 rubygems