Sha256: 0dad1430caa0ff69d364abc65a62d9a8499f4d2ab9412c1ca3b7818da86d7f13
Contents?: true
Size: 766 Bytes
Versions: 2
Compression:
Stored size: 766 Bytes
Contents
module Napa module GrapeHelpers def represent(data, with: nil, **args) raise ArgumentError.new(":with option is required") if with.nil? if data.respond_to?(:to_a) return { data: data.map{ |item| with.new(item).to_hash(args) } } else return { data: with.new(data).to_hash(args)} end end def present_error(code, message = '') Napa::JsonError.new(code, message) end def permitted_params(options = {}) options = { include_missing: false }.merge(options) declared(params, options) end # extend all endpoints to include this Grape::Endpoint.send :include, self if defined?(Grape) # rails 4 controller concern extend ActiveSupport::Concern if defined?(Rails) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
napa-0.4.0 | lib/napa/grape_extensions/grape_helpers.rb |
napa-0.3.0 | lib/napa/grape_extensions/grape_helpers.rb |