debounced 0.1.20 → 0.1.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0b2a5d98cbf80bf222866ad69db51d71b000ea1e13a7bf16d7ddc638aa91923
4
- data.tar.gz: f031cae66cd65f40da805111ac8b31140de3e901f19f742bffe1ab593627bb27
3
+ metadata.gz: '08e33800aa43c78d6be5abffcda05d1ca70e46436531f42f79193cbf1ab86059'
4
+ data.tar.gz: 455c57c30a34f260aeb6adf2e61c45c13b190d13b8e4236f324f6a703beab655
5
5
  SHA512:
6
- metadata.gz: d498b7e15fb3aef46c5789d1df43d143970daf40a48bd9f71d5f0664330cda646d9d6d36e8936a334acefdb62d40c3e966ccff7b5fcfeaabf2ea47cf41edada9
7
- data.tar.gz: 05ec409dbede721aab6457c29b564a8d8565d87208b3816ec37f1e8a4e3aa2049a4f663e8612e3969ab4e0023058e52f14351529f27f6e8eb710969d9be7b130
6
+ metadata.gz: 32a872b4f22b473ec19890db74d264a11931fc810c57d83f9d14e1ce1ff18f4eb2f5403b74d45feb16fdf27cd236886e19ba18f9096d6009bcc0a6aed574ce93
7
+ data.tar.gz: fabd72e50c1b94cbb4fcf2677306c360f8eb299e9eff14b7acb380b1737722e54e2ee5ec03ea58d76cdb82427cc5dca0b36542367748a30833ec288d3c553be8
@@ -3,7 +3,18 @@ require 'debug'
3
3
  module Debounced
4
4
  class Callback
5
5
 
6
- attr_reader :class_name, :params, :method_name, :method_params
6
+ attr_accessor :class_name, :params, :method_name, :method_params
7
+
8
+ ###
9
+ # Create a new callback object
10
+ # @param class_name [String] the name of the class to call the method on
11
+ # @param params [Hash] a hash of parameters to pass to the class initializer (optional)
12
+ # @param method_name [String] the name of the method to call.
13
+ # If the method is a class method, it should be prefixed with a "."
14
+ # If it is an instance method, it should be prefixed with a "#"
15
+ # @param method_params [Array] an array of parameters to pass to the method
16
+ # @return [Debounced::Callback]
17
+ # @note @params is ignored if the method is a class method
7
18
  def initialize(class_name:, params:, method_name:, method_params:)
8
19
  @class_name = class_name.to_s
9
20
  @params = params || {}
@@ -11,7 +22,7 @@ module Debounced
11
22
  @method_params = method_params || []
12
23
  end
13
24
 
14
- def self.json_create(data)
25
+ def self.parse(data)
15
26
  new(
16
27
  class_name: data['class_name'],
17
28
  params: data['params'],
@@ -30,9 +41,14 @@ module Debounced
30
41
  end
31
42
 
32
43
  def call
33
- Object.const_get(class_name)
34
- .new(**params.transform_keys(&:to_sym))
35
- .send(method_name, *method_params)
44
+ klass = Object.const_get(class_name)
45
+ message = method_name[1..-1] # strip of method_name prefix, either "." or "#"
46
+ target = klass
47
+ if method_name[0] == '#'
48
+ target = klass.new(**params.transform_keys(&:to_sym))
49
+ end
50
+ target.send(message, *method_params)
36
51
  end
52
+
37
53
  end
38
54
  end
@@ -116,7 +116,7 @@ module Debounced
116
116
  end
117
117
 
118
118
  def instantiate_callback(data)
119
- Callback.json_create(data)
119
+ Callback.parse(data)
120
120
  end
121
121
 
122
122
  def socket_descriptor
@@ -1,3 +1,3 @@
1
1
  module Debounced
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debounced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Passero