structure 0.27.8 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/structure.rb +16 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b00ee1d574dcbdc3668117ac11a31d88fe6e716e
|
4
|
+
data.tar.gz: 78d66f77d545b0f073abe82154b25c26a297fdf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d72544e4291e8f7ea6a614725a0b19fecabfb5777a80f5fab7d339fa777b631aa49bfd15918e6623aac54a59d9351f0315c1845bdeedd0cf43c426500e731d4
|
7
|
+
data.tar.gz: 00c05b68d2db9b84ca6acd6933f2613d105b751dc996ca74a73676ecfd748388de2cc16d5a50939b20b0386f30eefd03f6d90fe6cc437e6a782ff47b756dad4d
|
data/structure.rb
CHANGED
@@ -40,30 +40,25 @@ module Structure
|
|
40
40
|
module ClassMethods
|
41
41
|
attr_reader :attribute_names
|
42
42
|
|
43
|
-
def
|
44
|
-
|
43
|
+
def double(&blk)
|
44
|
+
klass = Class.new(self)
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
(private_instance_methods(false) + protected_instance_methods(false) - [:initialize])
|
47
|
+
.each do |mth|
|
48
|
+
klass.send(:undef_method, mth)
|
49
|
+
end
|
49
50
|
|
50
|
-
klass
|
51
|
+
klass.module_eval do
|
51
52
|
def initialize(data = {})
|
52
|
-
data.each { |key, val|
|
53
|
+
data.each { |key, val| instance_variable_set(:"@#{key}", val.freeze) }
|
53
54
|
end
|
54
|
-
end
|
55
|
-
|
56
|
-
klass.module_eval(&blk) if block_given?
|
57
55
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
attribute_names.each do |name|
|
64
|
-
if instance_methods(false).include?(:"#{name}?")
|
65
|
-
klass.module_eval "def #{name}?; #{name}; end"
|
56
|
+
attribute_names.each do |name|
|
57
|
+
module_eval "def _#{name}; @#{name}; end"
|
58
|
+
private "_#{name}"
|
66
59
|
end
|
60
|
+
|
61
|
+
module_eval(&blk) if block_given?
|
67
62
|
end
|
68
63
|
|
69
64
|
klass
|
@@ -73,10 +68,12 @@ module Structure
|
|
73
68
|
subclass.instance_variable_set(:@attribute_names, @attribute_names.dup)
|
74
69
|
end
|
75
70
|
|
71
|
+
private
|
72
|
+
|
76
73
|
def attribute(name, &blk)
|
77
74
|
name = name.to_s
|
78
75
|
module_eval "def #{name}?; #{name}; end" if name.chomp!('?')
|
79
|
-
module_eval "def #{name}; @#{name} ||= _#{name}; end"
|
76
|
+
module_eval "def #{name}; @#{name} ||= _#{name}.freeze; end"
|
80
77
|
define_method("_#{name}", blk)
|
81
78
|
private "_#{name}"
|
82
79
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: structure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: me@hakanensari.com
|