constructor_shortcut 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/constructor_shortcut.rb +22 -1
- data/lib/constructor_shortcut/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ca5cef9e697f913cad23d24772b5847dd15219d
|
4
|
+
data.tar.gz: '08e3e04d55494b5ce0824bafea68efc16e880384'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6413520908c2c051ebac1a40a6c55d6502c3ae80282721d47448e8085bc4c04b795bb5fbc4f65ce47bc02e67be1d25d5e99cddd8cc020f6f876ba4fe31874fa
|
7
|
+
data.tar.gz: 5cc0d0d19686046747ce0c37961d3c0eb27559ff022f6d72bd7e0021422cc4a23e613926cad50aa3cc72d355e9374099733e1a80fe96b7bf0a0ce656ab9f9339
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/
|
2
|
-
[![Build Status](https://travis-ci.org/
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/constructor_shortcut.svg)](https://badge.fury.io/rb/constructor_shortcut)
|
2
|
+
[![Build Status](https://travis-ci.org/gzigzigzeo/constructor_shortcut.svg?branch=master)](https://travis-ci.org/gzigzigzeo/constructor_shortcut)
|
3
3
|
|
4
4
|
# ConstructorShortcut
|
5
5
|
|
data/lib/constructor_shortcut.rb
CHANGED
@@ -1,11 +1,32 @@
|
|
1
1
|
require "constructor_shortcut/version"
|
2
2
|
require "constructor_shortcut/cache"
|
3
3
|
|
4
|
+
# rubocop:disable Metrics/MethodLength
|
5
|
+
|
4
6
|
# Generates anonymous module containing single class method
|
5
7
|
module ConstructorShortcut
|
6
8
|
# Used to set method name
|
7
9
|
def self.[](name = :call, class_name = :call)
|
8
|
-
|
10
|
+
@cache ||= {}
|
11
|
+
key = "#{name.inspect}, #{class_name.inspect}".freeze
|
12
|
+
|
13
|
+
@cache[key] ||=
|
14
|
+
Module.new do
|
15
|
+
@key = key
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def name
|
19
|
+
"ConstructorShortcut[#{@key}]"
|
20
|
+
end
|
21
|
+
alias_method :to_s, :name
|
22
|
+
alias_method :to_str, :name
|
23
|
+
alias_method :inspect, :name
|
24
|
+
end
|
25
|
+
|
26
|
+
define_method class_name do |*args, &block|
|
27
|
+
new(*args, &block).public_send(name)
|
28
|
+
end
|
29
|
+
end
|
9
30
|
end
|
10
31
|
|
11
32
|
def call(*args, &block)
|