stance 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4da3d0518f890cfeff617a5751efd1cfa9267735425489cd60fda3cc756fb7c3
4
- data.tar.gz: 63ed6c237aba36901be39c205b86f27339c2adc950a119a02eb70be8d9313827
3
+ metadata.gz: 51b0695fffdd5e9543b325277fabfd2244cac3a84ffefb2660ed9c48499bdf12
4
+ data.tar.gz: 28c77b84783964cc08617e2d28b8c1906105fe621b4ad83236bb571327e6dfc0
5
5
  SHA512:
6
- metadata.gz: 95260c2c651deebe0b4f00f667d9961c88128100e5d56cb5f956ae098af00e0421f35fdcbccf17ddd4fea63a8f5050206560c69c3daea18961b5a5501c364338
7
- data.tar.gz: 6c72c0b24be0c1a2ad4c5943914ee74c24ed9b1c3d70a5581429f445a81c27d183473a36885fe1ba0bf72afea929062c14107be489d65edd75413ac85c34a54d
6
+ metadata.gz: 2816cde14c5643554d55faa81122667e13b123bc8591e8d959d412a40e204b72aeca434b41a4b98a5270b07f828652f59064e60851c5e9e83a34aa21b6c97b52
7
+ data.tar.gz: '049bd51dd0ddb46eaa7e52b4a2fa0f7a709fd1c101510499637411c5d55e0ae374e5fca1de23a30760276213b1b38b43a56c353f392df9fe20272cee46eb0dcc'
@@ -6,6 +6,16 @@ require 'stance/engine'
6
6
  module Stance
7
7
  class EventNotFound < StandardError; end
8
8
 
9
+ mattr_accessor :disabled_events
10
+ @@disabled_events = []
11
+
12
+ def self.disable(*events)
13
+ disabled_events.concat events
14
+ yield
15
+ ensure
16
+ self.disabled_events -= events
17
+ end
18
+
9
19
  autoload :Events, 'stance/events'
10
20
  autoload :Event, 'stance/event'
11
21
  autoload :Eventable, 'stance/eventable'
@@ -21,9 +21,9 @@ module Stance
21
21
  event_class_name = "#{events_class_name}::#{name.to_s.tr('.', '/').classify}"
22
22
  ev = event_class(event_class_name).new(name, self, metadata, events_class.events[name])
23
23
 
24
- events_class.new(ev).run_callbacks :create do
25
- ev.create
26
- end
24
+ return ev if Stance.disabled_events.include?(ev.full_name)
25
+
26
+ events_class.new(ev).run_callbacks(:create) { ev.create }
27
27
  end
28
28
 
29
29
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stance
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-06 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord