adamantium 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/flay.yml +1 -1
- data/lib/adamantium.rb +1 -0
- data/lib/adamantium/mutable.rb +53 -0
- data/lib/adamantium/version.rb +2 -2
- data/spec/unit/adamantium/mutable/freeze_spec.rb +21 -0
- data/spec/unit/adamantium/mutable/frozen_predicate_spec.rb +17 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b0049e404dd0b6bead1b53497d23c5fb32ffc51
|
4
|
+
data.tar.gz: 3945219defdbbda61deaa701742d312329a6fd55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 452f5edf8c0a14edb3df5b85b9dc9510a7b22215be98359f131a579eb4436e96e4c6ad1512cbe9fe828becc635b339713e53dd9380d7822b7c5c6e60badee790
|
7
|
+
data.tar.gz: e3914061c61c9fc2cf29750a741e8c993a8492dafec7f41e127b29173e735ad0fc148e4acbc4a394fc2f27ab4976860500532fc13fdf1664e9448da972c045d1
|
data/config/flay.yml
CHANGED
data/lib/adamantium.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Adamantium
|
2
|
+
|
3
|
+
# Module fake frozen object
|
4
|
+
#
|
5
|
+
# This behavior sometimes is needed when a mutable
|
6
|
+
# object needs to be referenced in an inmutable object tree.
|
7
|
+
#
|
8
|
+
# If you have to use `memoize :foo, :freezer => :noop` to often you might
|
9
|
+
# want to include this module into your class.
|
10
|
+
#
|
11
|
+
# Use wisely! A rule of thumb only a tiny fraction of your objects
|
12
|
+
# typically deserves this.
|
13
|
+
#
|
14
|
+
module Mutable
|
15
|
+
|
16
|
+
# Noop freezer
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# class DoesNotGetFrozen
|
20
|
+
# include Adamantium::Mutable
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# instance = DoesNotGetFrozen
|
24
|
+
# instance.freeze # => instance
|
25
|
+
#
|
26
|
+
# @return [self]
|
27
|
+
#
|
28
|
+
# @api public
|
29
|
+
#
|
30
|
+
def freeze
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
# Test if object is frozen
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# class DoesNotGetFrozen
|
38
|
+
# include Adamantium::Mutable
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# instance = DoesNotGetFrozen
|
42
|
+
# instance.frozen? # => true
|
43
|
+
#
|
44
|
+
# @return [true]
|
45
|
+
#
|
46
|
+
# @api public
|
47
|
+
#
|
48
|
+
def frozen?
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
end # Mutable
|
53
|
+
end # Adamantium
|
data/lib/adamantium/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Adamantium::Mutable, '#freeze' do
|
4
|
+
subject { object.freeze }
|
5
|
+
|
6
|
+
let(:object) { class_under_test.new }
|
7
|
+
|
8
|
+
let(:class_under_test) do
|
9
|
+
Class.new do
|
10
|
+
include Adamantium::Mutable
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it_should_behave_like 'a command method'
|
15
|
+
|
16
|
+
it 'keeps object mutable' do
|
17
|
+
subject
|
18
|
+
object.instance_variable_set(:@foo, :bar)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Adamantium::Mutable, '#frozen?' do
|
4
|
+
subject { object.frozen? }
|
5
|
+
|
6
|
+
let(:object) { class_under_test.new }
|
7
|
+
|
8
|
+
let(:class_under_test) do
|
9
|
+
Class.new do
|
10
|
+
include Adamantium::Mutable
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it { should be(true) }
|
15
|
+
|
16
|
+
it_should_behave_like 'an idempotent method'
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adamantium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kubb
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ice_nine
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/adamantium/class_methods.rb
|
80
80
|
- lib/adamantium/freezer.rb
|
81
81
|
- lib/adamantium/module_methods.rb
|
82
|
+
- lib/adamantium/mutable.rb
|
82
83
|
- lib/adamantium/version.rb
|
83
84
|
- spec/integration/adamantium_spec.rb
|
84
85
|
- spec/rcov.opts
|
@@ -104,6 +105,8 @@ files:
|
|
104
105
|
- spec/unit/adamantium/module_methods/memoize_spec.rb
|
105
106
|
- spec/unit/adamantium/module_methods/memoized_predicate_spec.rb
|
106
107
|
- spec/unit/adamantium/module_methods/original_instance_method_spec.rb
|
108
|
+
- spec/unit/adamantium/mutable/freeze_spec.rb
|
109
|
+
- spec/unit/adamantium/mutable/frozen_predicate_spec.rb
|
107
110
|
homepage: https://github.com/dkubb/adamantium
|
108
111
|
licenses: []
|
109
112
|
metadata: {}
|
@@ -149,4 +152,6 @@ test_files:
|
|
149
152
|
- spec/unit/adamantium/module_methods/memoize_spec.rb
|
150
153
|
- spec/unit/adamantium/module_methods/memoized_predicate_spec.rb
|
151
154
|
- spec/unit/adamantium/module_methods/original_instance_method_spec.rb
|
155
|
+
- spec/unit/adamantium/mutable/freeze_spec.rb
|
156
|
+
- spec/unit/adamantium/mutable/frozen_predicate_spec.rb
|
152
157
|
has_rdoc:
|