countable_2023 0.1.0
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 +7 -0
- data/lib/countable_2023/version.rb +5 -0
- data/lib/countable_2023.rb +43 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 036a4ec509d5949c40d4b9b5a0e49cb44b4b1e8fbb9681818b963963ff2e5f56
|
|
4
|
+
data.tar.gz: a0e906e5c1dd8f584ae3fda5c5aca083da1ab303a63154c87dad19e4c47db8f6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 16da82b55893044e14f55d70638561d06d4211c26720677557017685a61b739b1c32c82b36d7f2f936e103444d0b0a9d0d4397f311a31f24d56d8b24dfe2a094
|
|
7
|
+
data.tar.gz: 8a70821545ef33ad349443027edfd0085bbd5c8263dd35f3043163a6916950d9d8ab8a3ca5b251e4ebf1c22e2d200e5b64e4547de18dce32def98e0667a5f53e
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "countable_2023/version"
|
|
4
|
+
|
|
5
|
+
module Countable2023
|
|
6
|
+
class Error < StandardError; end
|
|
7
|
+
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.extend(ClassMethods)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module ClassMethods
|
|
13
|
+
def count_invocations_of(sym)
|
|
14
|
+
@invocation_counts ||= {}
|
|
15
|
+
@invocation_counts[sym] ||= 0
|
|
16
|
+
|
|
17
|
+
original_method = instance_method(sym)
|
|
18
|
+
|
|
19
|
+
define_method(sym) do |*args, &block|
|
|
20
|
+
self.class.increment_invocation_count(sym)
|
|
21
|
+
original_method.bind(self).call(*args, &block)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def increment_invocation_count(sym)
|
|
26
|
+
@invocation_counts ||= {}
|
|
27
|
+
@invocation_counts[sym] ||= 0
|
|
28
|
+
@invocation_counts[sym] += 1
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def invocation_counts
|
|
32
|
+
@invocation_counts || {}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def invoked?(sym)
|
|
37
|
+
self.class.invocation_counts.key?(sym) && self.class.invocation_counts[sym] > 0
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def invoked(sym)
|
|
41
|
+
self.class.invocation_counts[sym] || 0
|
|
42
|
+
end
|
|
43
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: countable_2023
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- cololaborde
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-10-29 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Una descripción más detallada de tu gema.
|
|
14
|
+
email:
|
|
15
|
+
- cololaborde@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/countable_2023.rb
|
|
21
|
+
- lib/countable_2023/version.rb
|
|
22
|
+
homepage: https://github.com/tu_usuario/tu_gema
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata: {}
|
|
26
|
+
post_install_message:
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: 2.6.0
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubygems_version: 3.3.15
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Una breve descripción de tu gema
|
|
45
|
+
test_files: []
|