conjuration 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/conjuration/concerns/attributes.rb +25 -23
- data/lib/conjuration/managers/scene_manager.rb +1 -1
- data/lib/conjuration/version.rb +1 -1
- data/lib/conjuration.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e27fba626de7b8059165ffe52b623628c1c49bc61e075705b6cf20b4c9110ebf
|
4
|
+
data.tar.gz: fd3016c986e1efc324f0ab082676094afdee0584686e1c9c2c55c95edf276458
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 703d100ccfa5a015514bf0dfb62fec05de9c6dcff92e01046f5aa53c0075441767d816b0b1ac0fc15db348b4e5a95c599ca6c983c7298bca65d010d6316490f0
|
7
|
+
data.tar.gz: 0c1d933ef7492d6e357a0b6d60eb7976a29c7c177c6c7f378c3d8b568b91ef5d1cb3804bccffb03bbf3be26f6b599d4ffa963dc34afe87dab89f6998026a67c0
|
@@ -22,37 +22,39 @@
|
|
22
22
|
# person.age = 30
|
23
23
|
# person.inspect # => "<Person name: \"Alice\", age: 30>"
|
24
24
|
#
|
25
|
-
module
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
module Conjuration
|
26
|
+
module Attributes
|
27
|
+
def self.included(base)
|
28
|
+
base.extend(ClassMethods)
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
def initialize(...)
|
32
|
+
super()
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
@attributes = {}
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def inspect
|
38
|
+
"<#{self.class} #{@attributes.map { |attribute_name, value| "#{attribute_name}: #{value.inspect}" }.join(", ")}>"
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
module ClassMethods
|
42
|
+
def attribute(attribute_name)
|
43
|
+
define_method(attribute_name) do
|
44
|
+
@attributes[attribute_name]
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
define_method("#{attribute_name}=") do |value|
|
48
|
+
@attributes[attribute_name] = value
|
49
|
+
end
|
48
50
|
end
|
49
|
-
end
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
def boolean_attribute(attribute_name)
|
53
|
+
attribute(attribute_name)
|
53
54
|
|
54
|
-
|
55
|
-
|
55
|
+
define_method("#{attribute_name}?") do
|
56
|
+
!!@attributes[attribute_name]
|
57
|
+
end
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
data/lib/conjuration/version.rb
CHANGED
data/lib/conjuration.rb
CHANGED