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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5eff1d483904e69e76c1114b058358a6d2e5eb3b041a95fda5aa28f441700601
4
- data.tar.gz: 439d16d1874d455e85b76c53a79d3a147b2ff7ddea45be50e12d62881680940f
3
+ metadata.gz: 1dd6a8ee8dcab7026a1aad2d9e5dfd37c28ea95c8161912341e854532bc2cddd
4
+ data.tar.gz: 6f3a2a719d4c65c777eedc1bee4e993c37c379c0012f6838445c34af732f1101
5
5
  SHA512:
6
- metadata.gz: 2fe97f05b46bc6d60c2df137e5d87b67d2767f1ed36d6505d1f11817428304b61a36279b06e158f9745efaf59697ed3ac127952e03cd21e6996d3078d3805934
7
- data.tar.gz: 589cf58ab0cffc2e24f61726ddab0e4fc38a52cd4dc8379f8a3b4bb3dc1a3814e3b9649addfc819e00b77b913bf54c2992d89dc892a6e6d5942a2cf690c53330
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
- attr_accessor(*keys)
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
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Platform
3
- VERSION = '1.3.0'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
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.3.0
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-03-29 00:00:00.000000000 Z
11
+ date: 2018-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit-nuntius