callmeback 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
data/callmeback.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "callmeback"
8
- s.version = "1.2.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sebastien Azimi"]
data/lib/callmeback.rb CHANGED
@@ -6,16 +6,20 @@ module Callmeback
6
6
  include ActiveSupport::Callbacks
7
7
 
8
8
  included do
9
- # Initialize the callmeback methods and method index
10
- self.callmeback_methods = {}
11
- self.callmeback_method_index = 0
9
+ if defined?(Mongoid::Document)
10
+ after_initialize do
11
+ callback_binding
12
+ end
13
+ end
12
14
  end
13
15
 
14
16
  def initialize(*args, &block)
15
17
  super(*args, &block)
16
18
 
17
- # Overwrite the initialize method to perform the defined callbacks binding
18
- callback_binding
19
+ unless defined?(Mongoid::Document)
20
+ # Overwrite the initialize method to perform the defined callbacks binding
21
+ callback_binding
22
+ end
19
23
  end
20
24
 
21
25
  def callback_binding
@@ -63,8 +67,18 @@ module Callmeback
63
67
  end
64
68
 
65
69
  module ClassMethods
66
- attr_accessor :callmeback_methods
67
- attr_accessor :callmeback_method_index
70
+ attr_writer :callmeback_methods
71
+ attr_writer :callmeback_method_index
72
+
73
+ # Initialize the callmeback methods and method index
74
+ def callmeback_methods
75
+ @callmeback_methods ||= {}
76
+ end
77
+
78
+ # Initialize the callmeback methods and method index
79
+ def callmeback_method_index
80
+ @callmeback_method_index ||= 0
81
+ end
68
82
 
69
83
  [:before, :after, :around].each do |callback_prefix|
70
84
  define_method callback_prefix do |arg, &block|
@@ -1,6 +1,8 @@
1
1
  class Example
2
2
  include Callmeback
3
3
 
4
+ attr_accessor :result
5
+
4
6
  before :before_foo => :bar
5
7
  after :after_foo => :bar
6
8
  around :around_foo => :around_bar
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callmeback
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -192,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  segments:
194
194
  - 0
195
- hash: -529320161042203170
195
+ hash: -3698104378079920545
196
196
  required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  none: false
198
198
  requirements: