Sha256: 81b83f08dfeaca7db78e7c98f9a605a8cee5f2b9dc99fe33e09d2e32807fa5ed
Contents?: true
Size: 942 Bytes
Versions: 3
Compression:
Stored size: 942 Bytes
Contents
module Apiture class DefinitionValueRenderer def initialize(definition, all_definitions) @definition = definition @all_definitions = all_definitions end def render_parameter(parameter_name, env) context = env[:context] h = context.get_attribute(parameter_name) return nil unless h render(h) end def render(data) if @definition.kind_of? Swagger::ObjectDefinition render_object_def(data) elsif @definition.kind_of? Swagger::ArrayDefinition render_array_def(data) else raise Apiture::APIError, "Unsupported definition: #{@definition}" end end def render_object_def(hash) @definition.properties.reduce({}) do |memo, (name, _)| name = name.to_sym if hash[name] memo[name] = hash[name] end memo end end def render_array_def(array) array.dup end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
apiture-0.2.6 | lib/apiture/definition_value_renderer.rb |
apiture-0.2.5 | lib/apiture/definition_value_renderer.rb |
apiture-0.2.4 | lib/apiture/definition_value_renderer.rb |