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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 805b6127e506b5fe99c9bbe821c05d88d05d0de1
4
- data.tar.gz: 38ed163ac7c7571df6ffb6b2e76f4776d918df32
3
+ metadata.gz: 7ca5cef9e697f913cad23d24772b5847dd15219d
4
+ data.tar.gz: '08e3e04d55494b5ce0824bafea68efc16e880384'
5
5
  SHA512:
6
- metadata.gz: cb4b01f3d2161e8d3217425a295b6ca40dbd64631a1c961ddc88eb1710b638724c92ccbbce518ce0ffd8ff7eb7d559f464dab9bdb4336010043343e311e664e5
7
- data.tar.gz: 8ddd1b74de07d5a95f470a8fe1cc23e73b51de6360807d961fe60ab8d629e269277bf52e051f373d16364c21b8fcff9330c8dd24cbe0d127b79348a69df8b154
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/mobius-client.svg)](https://badge.fury.io/rb/constructor_shortcut)
2
- [![Build Status](https://travis-ci.org/mobius-network/mobius-client-ruby.svg?branch=master)](https://travis-ci.org/gzigzigzeo/constructor_shortcut)
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
 
@@ -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
- Cache.resolve(name, class_name)
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)
@@ -1,3 +1,3 @@
1
1
  module ConstructorShortcut
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constructor_shortcut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sokolov