tainbox 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/tainbox/attribute_definer.rb +6 -2
- data/lib/tainbox/deferred_value.rb +8 -0
- data/lib/tainbox/instance_methods.rb +0 -1
- data/lib/tainbox/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c180884b0471d64ec257abcb626c43cd59a79fe8
|
4
|
+
data.tar.gz: fcfd7c4fd5e0ab7f3f0ada8b04409363e55032a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f2941c17de11c3e083d3303ae87602d6f542b7ebfb7d586058278789c4e6c3e45f192b0193d6ecdbb23f24556e37052dab07e6d665bdb33b6a88602731b7bc
|
7
|
+
data.tar.gz: 77c030002c12e6f0e3aa7e1abe0b3135bded6d9d39cdf0d4a808e56decb99cc40180dfa44cddbff9b686f169c2ca52ef7826742d1b4560c5615c5946291ef023
|
data/.gitignore
CHANGED
@@ -2,6 +2,7 @@ require 'active_support/core_ext/object/deep_dup'
|
|
2
2
|
|
3
3
|
require_relative 'type_converter'
|
4
4
|
require_relative 'extensions'
|
5
|
+
require_relative 'deferred_value'
|
5
6
|
|
6
7
|
class Tainbox::AttributeDefiner
|
7
8
|
|
@@ -18,7 +19,8 @@ class Tainbox::AttributeDefiner
|
|
18
19
|
|
19
20
|
klass.tainbox_layer.instance_eval do
|
20
21
|
define_method(attribute) do
|
21
|
-
instance_variable_get(:"@#{attribute}")
|
22
|
+
value = instance_variable_get(:"@#{attribute}")
|
23
|
+
value.is_a?(Tainbox::DeferredValue) ? instance_exec(&value.proc) : value
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -41,7 +43,9 @@ class Tainbox::AttributeDefiner
|
|
41
43
|
define_method("tainbox_set_default_#{attribute}") do
|
42
44
|
if args.has_key?(:default)
|
43
45
|
tainbox_register_attribute_provided(attribute)
|
44
|
-
|
46
|
+
value = args[:default].deep_dup
|
47
|
+
value = Tainbox::DeferredValue.new(value) if value.is_a?(Proc)
|
48
|
+
instance_variable_set(:"@#{attribute}", value)
|
45
49
|
end
|
46
50
|
end
|
47
51
|
end
|
data/lib/tainbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tainbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Gubitskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/tainbox.rb
|
82
82
|
- lib/tainbox/attribute_definer.rb
|
83
83
|
- lib/tainbox/class_methods.rb
|
84
|
+
- lib/tainbox/deferred_value.rb
|
84
85
|
- lib/tainbox/extensions.rb
|
85
86
|
- lib/tainbox/instance_methods.rb
|
86
87
|
- lib/tainbox/type_converter.rb
|