rubydium 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubydium/mixins/command_macros.rb +28 -0
- data/lib/rubydium/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2e2772c99fcea22c7e44bf38e1f627f15e82c7e40f7d7098a0274899e1f6f96
|
4
|
+
data.tar.gz: acfaf6eab26a496487dc3ad068d94ee32fea757013e7b7f417488df5e1bc77f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5433732515339715ffce7a6a0a42c4fc16f305482605b2f7fe5021e76be5d95a32ecc70858d0f9685c874fa18e342b7eaa681e3ba658ae7d580041999e654da
|
7
|
+
data.tar.gz: 824cbea37e25519b5c3d1a1d1f845d1c4bd6c5eb52a29c9ecea6387302e4506055f6780492def00b594caf84ba81a1a1ed2ed6ef7c272fcd14c0fcd276cc12fe
|
@@ -10,6 +10,34 @@ module Rubydium
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
+
# Makes these actions work in inheritance as you would expect, i. e.:
|
14
|
+
#
|
15
|
+
# class ParentBot < Rubydium::Bot
|
16
|
+
# on_every_message :foo
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# class ChildBot < ParentBot
|
20
|
+
# on_every_message :bar
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# class AnotherChildBot < ParentBot
|
24
|
+
# on_every_message :baz
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# ParentBot.registered_on_every_message.map { _1[:action] } # => [:foo]
|
28
|
+
# ChildBot.registered_on_every_message.map { _1[:action] } # => [:foo, :bar]
|
29
|
+
# AnotherChildBot.registered_on_every_message.map { _1[:action] } # => [:foo, :baz]
|
30
|
+
def inherited(subclass)
|
31
|
+
%w[
|
32
|
+
@registered_on_mention
|
33
|
+
@registered_on_every_message
|
34
|
+
@registered_commands
|
35
|
+
].each do |var_name|
|
36
|
+
current_value_copy = instance_variable_get(var_name).dup
|
37
|
+
subclass.instance_variable_set(var_name, current_value_copy)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
13
41
|
def on_mention(method_name=nil, ignore_forwarded: true, &block)
|
14
42
|
@registered_on_mention ||= []
|
15
43
|
action = (method_name || block)
|
data/lib/rubydium/version.rb
CHANGED