mumukit-platform 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mumukit/platform/model.rb +18 -6
- data/lib/mumukit/platform/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dd6a8ee8dcab7026a1aad2d9e5dfd37c28ea95c8161912341e854532bc2cddd
|
4
|
+
data.tar.gz: 6f3a2a719d4c65c777eedc1bee4e993c37c379c0012f6838445c34af732f1101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c74ac7c87e61ef21fe636d79704c24437bb22ca788ce27b1c0ee7940e67a59caae1f5eed2ad43c9142479d5e75e77b63ca582f986f3907e27a7f2fa045bf07f7
|
7
|
+
data.tar.gz: 325795fc6406cfcbdaad8c9285a15db6a354fed5ead11d5b0f3152b25d892ffc594d735df1391ab319590c012c2d4e1a4673d74ad6a65751dac3ad2494c5ee99
|
@@ -7,17 +7,15 @@ class Mumukit::Platform::Model
|
|
7
7
|
as_json.empty?
|
8
8
|
end
|
9
9
|
|
10
|
+
## Accessors
|
11
|
+
|
10
12
|
def self.model_attr_accessor(*keys)
|
11
13
|
bools, raws = keys.partition { |it| it.to_s.end_with? '?' }
|
12
14
|
raw_bools = bools.map { |it| it.to_s[0..-2].to_sym }
|
13
15
|
keys = raws + raw_bools
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
raw_bools.each do |it|
|
18
|
-
define_method("#{it}?") { !!send(it) }
|
19
|
-
define_method("#{it}=") { |value| instance_variable_set("@#{it}", value.to_boolean) }
|
20
|
-
end
|
17
|
+
define_attr_readers keys, raw_bools
|
18
|
+
define_attr_writers keys, raw_bools
|
21
19
|
|
22
20
|
# Parses model from an event.
|
23
21
|
# Only allowed keys are accepted
|
@@ -26,6 +24,20 @@ class Mumukit::Platform::Model
|
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
27
|
+
# Define the attribute readers for the model,
|
28
|
+
# given the normal accessor names and the boolean accessor names
|
29
|
+
def self.define_attr_readers(readers, bool_readers)
|
30
|
+
attr_reader(*readers)
|
31
|
+
bool_readers.each { |it| define_method("#{it}?") { !!send(it) } }
|
32
|
+
end
|
33
|
+
|
34
|
+
# Define the attribute writers for the model,
|
35
|
+
# given the normal accessor names and the boolean accessor names
|
36
|
+
def self.define_attr_writers(writers, bool_writers)
|
37
|
+
attr_writer(*writers)
|
38
|
+
bool_writers.each { |it| define_method("#{it}=") { |value| instance_variable_set("@#{it}", value.to_boolean) } }
|
39
|
+
end
|
40
|
+
|
29
41
|
## Serialization
|
30
42
|
|
31
43
|
# Serializes model
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumukit-platform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit-nuntius
|