module IntrospectiveGrape::Helpers
Constants
- API_ACTIONS
Public Instance Methods
all_or_none(args=[])
click to toggle source
# File lib/introspective_grape/helpers.rb, line 40 def all_or_none(args=[]) args.flatten!&.compact! args = API_ACTIONS if args.include?(:all) args = [] if args.include?(:none) args end
authentication_method(context)
click to toggle source
# File lib/introspective_grape/helpers.rb, line 10 def authentication_method(context) # Default to "authenticate!" or as grape docs once suggested, "authorize!" if @authentication_method @authentication_method elsif context.respond_to?('authenticate!') 'authenticate!' elsif context.respond_to?('authorize!') 'authorize!' end end
authentication_method=(method)
click to toggle source
# File lib/introspective_grape/helpers.rb, line 5 def authentication_method=(method) # IntrospectiveGrape::API.authentication_method= @authentication_method = method end
default_includes(model, *args)
click to toggle source
# File lib/introspective_grape/helpers.rb, line 53 def default_includes(model, *args) @default_includes ||= {} @default_includes[model.name] = args.present? ? args.flatten : @default_includes[model.name] || [] end
exclude_actions(model, *args)
click to toggle source
# File lib/introspective_grape/helpers.rb, line 29 def exclude_actions(model, *args) args = all_or_none(args) @exclude_actions ||= {} @exclude_actions[model.name] ||= [] undefined_actions = args - API_ACTIONS raise "#{model.name} defines invalid actions: #{undefined_actions}" if undefined_actions.present? @exclude_actions[model.name] = args.present? ? args : @exclude_actions[model.name] end
include_actions(model, *args)
click to toggle source
# File lib/introspective_grape/helpers.rb, line 47 def include_actions(model, *args) @exclude_actions ||= {} @exclude_actions[model.name] ||= [] @exclude_actions[model.name] = API_ACTIONS - exclude_actions(model, args) end
paginate(args={})
click to toggle source
# File lib/introspective_grape/helpers.rb, line 21 def paginate(args={}) @pagination = args end
pagination()
click to toggle source
# File lib/introspective_grape/helpers.rb, line 25 def pagination @pagination end
skip_presence_validations(fields=nil)
click to toggle source
# File lib/introspective_grape/helpers.rb, line 64 def skip_presence_validations(fields=nil) return @skip_presence_fields || [] unless fields @skip_presence_fields = [fields].flatten end
whitelist(whitelist=nil)
click to toggle source
# File lib/introspective_grape/helpers.rb, line 58 def whitelist(whitelist=nil) return @whitelist unless whitelist @whitelist = whitelist end