stance 0.8.1 → 0.8.2

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: 369e98673ef67283f9b65048d4a5163eb1de066fac3178554e78c8fbd720dc41
4
- data.tar.gz: 4cfdcd75169331697db547c7e922ee2f61dc4aa472b8de6f4dab522ee6038ed1
3
+ metadata.gz: f679d8376ef01172a2fe04995062885020f1810423df94a0621c3d863262267b
4
+ data.tar.gz: 2941c4c5af5f147eb0105294e19c3d23a7e9b8887fbc67661ea4e59bb14791f0
5
5
  SHA512:
6
- metadata.gz: e2d23c6aa87c81f4fd6d60472aad3e5ac9fbfd93731e06e7da10dc5f9ea3796f90a6ea94f36beec46fac829474b70eaa909e836a0b91a9c30f959ffcb89704bf
7
- data.tar.gz: beee74748db0d933c8af8a209ecf2e99d226df1d07f4c731cdd7ba917cdb2ce605f983eef994dda9e19bf0c530c6977570a360e1fac5cc13813313ca1057888b
6
+ metadata.gz: '080ac5b578744bcd5103b049f103718b9bb8ffc5ef878893da96f4618e1097b4b5c4b3ea1296d4f8f06578701b2b2ddc881773623d20c76ce685755c97bf7954'
7
+ data.tar.gz: 7cdad4e4fd10b3c53081bbca1def4134efdb9d83ec5f4e40991e7238e2451d0b270a1874c27a0f4a1def5cc31f37bce238c893f7ffb03dcd013ab93c61e46c3b
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ gemspec
7
7
 
8
8
  gem 'autotest-suffix'
9
9
  gem 'combustion'
10
+ gem 'debug'
10
11
  gem 'minitest'
11
12
  gem 'minitest-autotest'
12
13
  gem 'minitest-focus'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stance (0.8.1)
4
+ stance (0.8.2)
5
5
  multi_json (~> 1.15)
6
6
  rails (>= 7.0, < 8.0)
7
7
 
@@ -95,6 +95,9 @@ GEM
95
95
  connection_pool (2.4.1)
96
96
  crass (1.0.6)
97
97
  date (3.3.4)
98
+ debug (1.9.1)
99
+ irb (~> 1.10)
100
+ reline (>= 0.3.8)
98
101
  drb (2.2.0)
99
102
  ruby2_keywords
100
103
  erubi (1.12.0)
@@ -237,6 +240,7 @@ PLATFORMS
237
240
  DEPENDENCIES
238
241
  autotest-suffix
239
242
  combustion
243
+ debug
240
244
  minitest
241
245
  minitest-autotest
242
246
  minitest-focus
@@ -56,7 +56,7 @@ module Stance
56
56
  end
57
57
 
58
58
  unless connection.adapter_name =~ /postg|mysql/i
59
- serialize :metadata, ::JSONWithIndifferentAccess
59
+ serialize :metadata, coder: ::JSONWithIndifferentAccess
60
60
  end
61
61
  end
62
62
  end
data/lib/stance/event.rb CHANGED
@@ -8,6 +8,8 @@ module Stance
8
8
  attr_reader :record, :options, :name
9
9
 
10
10
  class << self
11
+ attr_accessor :callback_methods
12
+
11
13
  def before_create(*methods, &block)
12
14
  set_callback :create, :before, *methods, &block
13
15
  end
@@ -15,6 +17,15 @@ module Stance
15
17
  def after_create(*methods, &block)
16
18
  set_callback :create, :after, *methods, &block
17
19
  end
20
+
21
+ def method_added(method_name)
22
+ super
23
+
24
+ return if self == Stance::Event
25
+
26
+ self.callback_methods ||= []
27
+ self.callback_methods << method_name
28
+ end
18
29
  end
19
30
 
20
31
  def initialize(name, subject, metadata, options)
@@ -44,9 +55,9 @@ module Stance
44
55
  run_callbacks :create do
45
56
  # Call each public method of the Event class if a custom class.
46
57
  if self.class.name != 'Stance::Event'
47
- Rails.logger.info "Event: #{full_name}"
58
+ Rails.logger.debug "Event: #{full_name}"
48
59
 
49
- callback_methods.each { |method| send method }
60
+ self.class.callback_methods&.each { |method| send method }
50
61
  end
51
62
 
52
63
  record.save if @options[:record]
@@ -66,10 +77,6 @@ module Stance
66
77
 
67
78
  private
68
79
 
69
- def callback_methods
70
- public_methods(false) - Stance::Event.instance_methods(false)
71
- end
72
-
73
80
  # Event is a singleton and already exists.
74
81
  def singleton_exists?
75
82
  options[:singleton] && subject.events.active.exists?(name: name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stance
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss