module Caprese::Serializer::Relationships

Public Instance Methods

relationship_scope(name, scope) click to toggle source

Applies further scopes to a singular or collection association when rendered as part of included document @note Can be overridden to customize scoping at a per-relationship level

@example

def relationship_scope(name, scope)
  case name
  when :transactions
    scope.by_merchant(...)
  when :orders
    scope.by_user(...)
  when :user
    # change singular user response
  end
end

@param [String] name the name of the association @param [Relation,Record] scope the scope corresponding to a collection association relation or singular record

# File lib/caprese/serializer/concerns/relationships.rb, line 25
def relationship_scope(name, scope)
  scope
end