evnt 2.1.3 → 2.1.4

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
  SHA1:
3
- metadata.gz: 28c0022c15250f518920a8f8e236910a4a662b99
4
- data.tar.gz: a05ee20f2363290ee092a04cbd1bb8f51891d0ea
3
+ metadata.gz: 5743beb843869cb039a5007f7ef2ed7787612a43
4
+ data.tar.gz: 12c347e20764ba89c54534b3d500504ad1622d8c
5
5
  SHA512:
6
- metadata.gz: 75a4217bd3abf0e4f38282f5d754b85c63fa6f6f7491b88da2a79553e4af482eaa650d348f5a27748da054b9300ec2c5d6fda18f12499d4109a9aac57856e65f
7
- data.tar.gz: 7f3136bd5757a8175fe056a321050c36afb68907eab11ce3c79434bd14bf253830604d1c052c4009f94530e09518e08aa71be3b6e87cb398d31a4215869bf7ad
6
+ metadata.gz: 1bf390c6af6ddd639107fc025df2e9d72ed60e6e7ce767500c0328adf3ceb7cb5aafcc034f9dd77474ea5231726f1e5d67e7498bbcd3731832d1282cced709ea
7
+ data.tar.gz: 4aefe2b569c630440e9cb7d8d2e911aa3fc3e524448b36cb89d9f4f115c88234a2782ce590777b31f2b2e34599556993c8dd874f790601b15c82fcf9f0d79eac
data/lib/evnt/handler.rb CHANGED
@@ -21,7 +21,6 @@ module Evnt
21
21
  ##
22
22
  def notify(event)
23
23
  _init_handler_data(event)
24
- _init_handler_steps
25
24
  _run_handler_steps
26
25
  end
27
26
 
@@ -35,23 +34,20 @@ module Evnt
35
34
  @event = event
36
35
  end
37
36
 
38
- # This function init the handler steps.
39
- def _init_handler_steps
40
- self.class._events[@event.name].call
41
- end
42
-
43
37
  # This function calls requested steps for the handler.
44
38
  def _run_handler_steps
45
- _update_queries if defined?(_update_queries)
39
+ update_queries = "#{@event.name}_update_queries"
40
+ send(update_queries) if respond_to? update_queries
46
41
 
47
- # manage event reloaded
48
42
  if event.reloaded?
49
- _manage_reloaded_event if defined?(_manage_reloaded_event)
50
- return
43
+ # manage event reloaded
44
+ manage_reloaded_event = "#{@event.name}_manage_reloaded_event"
45
+ send(manage_reloaded_event) if respond_to? manage_reloaded_event
46
+ else
47
+ # manage normal event
48
+ manage_event = "#{@event.name}_manage_event"
49
+ send(manage_event) if respond_to? manage_event
51
50
  end
52
-
53
- # manage normal event
54
- _manage_event if defined?(_manage_event)
55
51
  end
56
52
 
57
53
  # Class functions:
@@ -60,27 +56,25 @@ module Evnt
60
56
  # This class contain the list of settings for the handler.
61
57
  class << self
62
58
 
63
- attr_accessor :_events
64
-
65
59
  # This function sets the blocks executed for a specific event.
66
60
  def on(event_name, &block)
67
- instance_variable_set(:@_events, {}) unless @_events
68
- @_events[event_name] = block
61
+ @_current_event_name = event_name
62
+ block.yield
69
63
  end
70
64
 
71
65
  # This function sets the update queries function for the event.
72
66
  def to_update_queries(&block)
73
- define_method('_update_queries', &block)
67
+ define_method("#{@_current_event_name}_update_queries", &block)
74
68
  end
75
69
 
76
70
  # This function sets the manage event function for the event.
77
71
  def to_manage_event(&block)
78
- define_method('_manage_event', &block)
72
+ define_method("#{@_current_event_name}_manage_event", &block)
79
73
  end
80
74
 
81
75
  # This function sets the manage reloaded event function for the event.
82
76
  def to_manage_reloaded_event(&block)
83
- define_method('_manage_reloaded_event', &block)
77
+ define_method("#{@_current_event_name}_manage_reloaded_event", &block)
84
78
  end
85
79
 
86
80
  end
data/lib/evnt/version.rb CHANGED
@@ -5,6 +5,6 @@ module Evnt
5
5
  ##
6
6
  # Constant containing the current gem version.
7
7
  ##
8
- VERSION = '2.1.3'
8
+ VERSION = '2.1.4'
9
9
 
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evnt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ideonetwork