class Rpush::ReflectionCollection

Constants

DEPRECATIONS
REFLECTIONS

Public Class Methods

new() click to toggle source
# File lib/rpush/reflection_collection.rb, line 25
def initialize
  @reflections = {}
end

Public Instance Methods

__dispatch(reflection, *args) click to toggle source
# File lib/rpush/reflection_collection.rb, line 29
def __dispatch(reflection, *args)
  blk = @reflections[reflection]

  if blk
    blk.call(*args)

    if DEPRECATIONS.key?(reflection)
      replacement, removal_version = DEPRECATIONS[reflection]
      Rpush::Deprecation.warn("#{reflection} is deprecated and will be removed in version #{removal_version}. Use #{replacement} instead.")
    end
  elsif !REFLECTIONS.include?(reflection)
    raise NoSuchReflectionError, reflection
  end
end