Sha256: 45e92af9ac4fe7bf97d8adf579ee9f820f5d3299e92223e576512b0d76156c6a
Contents?: true
Size: 993 Bytes
Versions: 9
Compression:
Stored size: 993 Bytes
Contents
module Rpush def self.plugin(name) plugins[name] ||= Rpush::Plugin.new(name) plugins[name] end def self.plugins @plugins ||= {} end class Plugin attr_reader :name, :config, :init_block attr_accessor :url, :description def initialize(name) @name = name @url = nil @description = nil @config = OpenStruct.new @reflection_collection = Rpush::ReflectionCollection.new @init_block = -> {} end def reflect yield(@reflection_collection) return if Rpush.reflection_stack.include?(@reflection_collection) Rpush.reflection_stack << @reflection_collection end def configure yield(@config) Rpush.config.plugin.send("#{@name}=", @config) end def init(&block) # rubocop:disable Style/TrivialAccessors @init_block = block end def unload Rpush.reflection_stack.delete(@reflection_collection) Rpush.config.plugin.send("#{name}=", nil) end end end
Version data entries
9 entries across 9 versions & 1 rubygems