Class: PubSub::Subscriptions
- Inherits:
-
Object
- Object
- PubSub::Subscriptions
- Includes:
- Singleton
- Defined in:
- lib/pub_sub/subscriptions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clear! ⇒ Object
-
#initialize ⇒ Subscriptions
constructor
A new instance of Subscriptions.
- #lint! ⇒ Object
- #register(scope = :all) ⇒ Object
Constructor Details
#initialize ⇒ Subscriptions
Returns a new instance of Subscriptions.
25 26 27 |
# File 'lib/pub_sub/subscriptions.rb', line 25 def initialize @config = YAML.load_file(self.class.subscriptions_path) end |
Class Method Details
.lint! ⇒ Object
17 18 19 |
# File 'lib/pub_sub/subscriptions.rb', line 17 def self.lint! instance.lint! end |
.load! ⇒ Object
12 13 14 15 |
# File 'lib/pub_sub/subscriptions.rb', line 12 def self.load! PubSub.subscriptions = Subscriptions.instance PubSub.subscriptions.register(:all) end |
Instance Method Details
#clear! ⇒ Object
41 42 43 |
# File 'lib/pub_sub/subscriptions.rb', line 41 def clear! Wisper.clear end |
#lint! ⇒ Object
21 22 23 |
# File 'lib/pub_sub/subscriptions.rb', line 21 def lint! Linter.new(config).lint! end |
#register(scope = :all) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pub_sub/subscriptions.rb', line 29 def register(scope = :all) (scope == :all ? config : config.slice(scope.to_s)).each do |domain_name, subscriptions| subscriptions.each do |event_name, subscription_type| = {} [:on] = event_name unless event_name == 'all_events' [:broadcaster] = subscription_type == 'sync' ? :default : subscription_type.to_sym Wisper.subscribe("::#{domain_name.camelize}".constantize, ) end end end |