lib/strongbolt/user_abilities.rb
def owns? instance
        raise ArgumentError unless instance.is_a?(Object) && !instance.is_a?(Class)
        # If the user id is set, does this (a) user id match the user_id field of the instance
        # or (b) if this is a User instance, does the user id match the instance id?
        key = instance.is_a?(User) ? :id : :user_id
        return !id.nil? && instance.try(key) == id
      end
#
# Checks if the user owns the instance given
#
Checks if the user owns the instance given
Checks if the user owns the instance given
def owns? instance
        raise ArgumentError unless instance.is_a?(Object) && !instance.is_a?(Class)
        key = instance.is_a?(User) ? :id : :user_id
        return !id.nil? && instance.try(key) == id
      end
def owns? instance raise ArgumentError unless instance . is_a? ( Object ) && ! instance . is_a? ( Class ) key = instance . is_a? ( User ) ? :id : :user_id return ! id . nil? && instance . try ( key ) == id end
Checks if the user owns the instance given
Checks if the user owns the instance given
# If the user id is set, does this (a) user id match the user_id field of the instance # or (b) if this is a User instance, does the user id match the instance id?
instance