Sha256: 91d167ea098c09627a337e56c9ee6637e35125c4c5645a6d12a15ce891e3163b
Contents?: true
Size: 866 Bytes
Versions: 1
Compression:
Stored size: 866 Bytes
Contents
require 'active_support/concern' module Onsi module Controller extend ActiveSupport::Concern module ClassMethods def render_version(version = nil) @render_version = version if version @render_version end end def render_resource(resource, opts = {}) version = opts.delete(:version) || self.class.render_version || Model::DEFAULT_API_VERSION payload = format_resource(resource, version) render_options = {} render_options[:json] = { data: payload } render_options.merge!(opts) render(render_options) end def format_resource(resource, version) case resource when Onsi::Resource resource when Enumerable resource.map { |res| format_resource(res, version) } else Onsi::Resource.new(resource, version) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
onsi-0.2.0 | lib/onsi/controller.rb |