smart_engine 0.9.0 → 0.10.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
  SHA256:
3
- metadata.gz: 72ab66864ab2ec1673cfcb6d48f0168560c9d7a843b2851f783f16d7bdb4fc63
4
- data.tar.gz: 3c0c6273fbfce55343452efd6bcaa2726bdfaf8133a46b06ac69fb40762649cf
3
+ metadata.gz: 443ea1ba136017a41b8468a0f266bfe9c061acf1f18edff4feafc12cfd362fce
4
+ data.tar.gz: ab2383e7cc554912b6f1e6b17686760e016f22887d19c9c883b4223302d3f354
5
5
  SHA512:
6
- metadata.gz: 8636209698ee6628cdc00af681b2400ffa6e7f4c479a3b2ae7a8cb9fdd14105a5c976791eadf541e56f1c41d719dd3d9c12adae2771468e3ba8c2be25e38a431
7
- data.tar.gz: e886baa10d5c4d81b00b35e6c27b2ad60f2cd640acc8e57d22f9903596b475d53c9dce6c25b37f9abba11e1331e8b60705a87da15b5f0b904471d38529e9fdda
6
+ metadata.gz: ba16d175ec535c9fc17cfea114fd1251e0d61cd0218dfeb0e6e940f7aa38a646523c27bdeff4ab88f5e8926c1ec703524a5ffa9736ddd7ed4b4b3284ea7d6866
7
+ data.tar.gz: 7862ff86af8da43fa843beb4c9613eff3e06f463ac5e99f4255333af566fd30cae833bf772e402259a533a08999f5d1c97113f3df45759db7405b4febb1059a6
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.10.0] - 2020-12-22
5
+ ### Added
6
+ - Support for `#hash` and `#instance_of?` for `SmartCore::Ext::BasicObjectAsObject` refinement;
7
+
4
8
  ## [0.9.0] - 2020-12-20
5
9
  ### Added
6
10
  - New type of utilities: *Extensions* (`SmartCore::Ext`);
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_engine (0.9.0)
4
+ smart_engine (0.10.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -99,12 +99,15 @@ object.frozen? # => true
99
99
 
100
100
  ### Basic Object Refinements
101
101
 
102
- Ruby's `BasicObject` class does not have some fundamental (extremely important) methods:
102
+ Ruby's `BasicObject` class does not have some fundamental (extremely important for instrumenting) methods:
103
103
 
104
104
  - `is_a?` / `kind_of?`
105
+ - `instance_of?`
105
106
  - `freeze` / `frozen?`
107
+ - `hash`
108
+ - `nil?`
106
109
 
107
- `SmartCore::Ext::BasicObjectAsObject` refinement solves this problem.
110
+ `SmartCore::Ext::BasicObjectAsObject` refinement solves this problem (by Ruby's internal API without any manualy-emulated behavior).
108
111
 
109
112
  ```ruby
110
113
  # without refinement:
@@ -112,6 +115,7 @@ basic_obj = ::BasicObject.new
112
115
 
113
116
  basic_obj.is_a?(::BasicObject) # raises ::NoMethodError
114
117
  basic_obj.kind_of?(::BasicObject) # raises ::NoMethodError
118
+ basic_obj.instance_of?(::BasicObject) # rasies ::NoMethodError
115
119
  basic_obj.freeze # raises ::NoMethodError
116
120
  basic_obj.frozen? # raises ::NoMethodError
117
121
  ```
@@ -123,7 +127,9 @@ using SmartCore::Ext::BasicObjectAsObject
123
127
  basic_obj = ::BasicObject.new
124
128
 
125
129
  basic_obj.is_a?(::BasicObject) # => true
126
- basic_obj.kind_of?(::BasicObject)
130
+ basic_obj.kind_of?(::BasicObject) # => true
131
+ basic_obj.instance_of?(::BasicObject) # => true
132
+ basic_obj.instance_of?(::Object) # => false
127
133
  basic_obj.is_a?(::Integer) # => false
128
134
  basic_obj.kind_of?(::Integer) # => false
129
135
 
@@ -6,7 +6,7 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- # @version 0.9.0
10
- VERSION = '0.9.0'
9
+ # @version 0.10.0
10
+ VERSION = '0.10.0'
11
11
  end
12
12
  end
@@ -2,13 +2,17 @@
2
2
 
3
3
  # @api public
4
4
  # @since 0.9.0
5
+ # @version 0.10.0
5
6
  module SmartCore::Ext::BasicObjectAsObject
6
7
  refine BasicObject do
7
8
  _m_obj = ::Object.new
8
9
 
9
- _is_a = _m_obj.method(:is_a?).unbind.tap(&:freeze)
10
- _freeze = _m_obj.method(:freeze).unbind.tap(&:freeze)
11
- _frozen = _m_obj.method(:frozen?).unbind.tap(&:freeze)
10
+ _is_a = _m_obj.method(:is_a?).unbind.tap(&:freeze)
11
+ _freeze = _m_obj.method(:freeze).unbind.tap(&:freeze)
12
+ _frozen = _m_obj.method(:frozen?).unbind.tap(&:freeze)
13
+ _hash = _m_obj.method(:hash).unbind.tap(&:freeze)
14
+ _nil = _m_obj.method(:nil?).unbind.tap(&:freeze)
15
+ _instance_of = _m_obj.method(:instance_of?).unbind.tap(&:freeze)
12
16
 
13
17
  # @note Object#is_a? behavior copy
14
18
  # @param klass [Class]
@@ -38,5 +42,29 @@ module SmartCore::Ext::BasicObjectAsObject
38
42
  define_method(:frozen?) do
39
43
  _frozen.bind(self).call
40
44
  end
45
+
46
+ # @return [Integer]
47
+ #
48
+ # @api public
49
+ # @since 0.10.0
50
+ define_method(:hash) do
51
+ _hash.bind(self).call
52
+ end
53
+
54
+ # @return [Boolean]
55
+ #
56
+ # @api public
57
+ # @since 0.10.0
58
+ define_method(:nil?) do
59
+ _nil.bind(self).call
60
+ end
61
+
62
+ # @return [Boolean]
63
+ #
64
+ # @api public
65
+ # @since 0.1.0
66
+ define_method(:instance_of?) do |klass|
67
+ _instance_of.bind(self).call(klass)
68
+ end
41
69
  end
42
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-19 00:00:00.000000000 Z
11
+ date: 2020-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler