Sha256: 92e209f404252dac60287cd60108abb3c2318a738a3b9c9af2389ea320152c7b
Contents?: true
Size: 1.08 KB
Versions: 12
Compression:
Stored size: 1.08 KB
Contents
require 'ixtlan/babel/params_filter' module CubaApi module InputFilter module ClassMethods def factory @_factory ||= Ixtlan::Babel::Factory.new end end def new_instance( clazz, context = nil ) filter = self.class.factory.new_params_filter( clazz ).use( context ) filter.new( parse_request_body ) end def params( clazz = nil, context = nil ) filter_params_and_keeps( clazz, context ) @_data[ 0 ] || {} end def keeps( clazz = nil, context = nil ) filter_params_and_keeps( clazz, context ) @_data[ 1 ] || {} end def filter_params_and_keeps( clazz, context ) if clazz @_data ||= begin filter = self.class.factory.new_filter( clazz ).use( context ) filter.filter_it( parse_request_body ) end end end private :filter_params_and_keeps def parse_request_body if env[ 'CONTENT_TYPE' ] == 'application/json' JSON.parse( req.body.read ) else {} end end protected :parse_request_body end end
Version data entries
12 entries across 12 versions & 1 rubygems