class GrapeTokenAuth::ResourceCrudBase

Attributes

configuration[R]
errors[R]
params[R]
resource[R]
resource_class[R]
scope[R]

Public Class Methods

new(params, configuration = nil, scope = :user) click to toggle source
# File lib/grape_token_auth/resource/resource_crud_base.rb, line 6
def initialize(params, configuration = nil, scope = :user)
  @configuration = configuration || GrapeTokenAuth.configuration
  @params = params
  @errors = []
  @scope = scope
end

Protected Instance Methods

permitted_params() click to toggle source
# File lib/grape_token_auth/resource/resource_crud_base.rb, line 28
def permitted_params
  permitted_attributes.each_with_object({}) do |key, permitted|
    value = Utility.find_with_indifference(params, key)
    permitted[key] = value if value
  end
end
pull_validation_messages() click to toggle source
# File lib/grape_token_auth/resource/resource_crud_base.rb, line 22
def pull_validation_messages
  @resource.errors.messages.map do |k, v|
    v.each { |e| errors << "#{k} #{e}" }
  end
end
validate_scope!() click to toggle source
# File lib/grape_token_auth/resource/resource_crud_base.rb, line 17
def validate_scope!
  @resource_class = configuration.scope_to_class(scope)
  fail ScopeUndefinedError.new(nil, scope) unless resource_class
end