mumukit-platform 2.5.0 → 2.6.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: 98e4aa5b3322ce4fe7e3dd2bae1c2b198739205a0bd501f817921d7d82791f30
4
- data.tar.gz: b4fdc1fbae3832061c27a7c713fd18da1bad026d0f834491dabada907d94f22f
3
+ metadata.gz: 347b67e0af757d17cff23a45abeab42998e75426ec534c8d438683ad22736572
4
+ data.tar.gz: 199bed2e1f9e605540fc175011dbab337f7c3b2b4a40e6f32c0e41632447bde1
5
5
  SHA512:
6
- metadata.gz: b883aef94bafc392e5d630666b54498959a66ba248c13e49a98e39bd14a625e4f2dadfb5ca345b5144eaa90a6f331c93b8a4febcf251e6e10ee1fbffef91cd27
7
- data.tar.gz: b75ec03c7ea60aa2561d7e91450b1a6bfd3b5b0f0998b9318e1006465f549f4753487e1a06a71317cbd3b9bd0d8df3cf5878b12822f7b45471e732f68732fd90
6
+ metadata.gz: cc386f8404e7f9b897f9b971531f564b0ff0ef375ba37e1f70b94609c2f1ae8bac3af6acb99e86eddeb7a8f0e4c881d7e6caad43abb387f1c02f43cf85074d8f
7
+ data.tar.gz: 82ce465f240cbac941b8d439b30869e4019e20805fc8c38d0ae58b664abfa502d562ee44057a2c9394119ce56e3099a7681f98380c81e0e8e27c935f1b1d1b64
@@ -3,25 +3,41 @@ require 'active_model'
3
3
  class Mumukit::Platform::Model
4
4
  include ActiveModel::Model
5
5
 
6
+ class_attribute :readers, :attributes
7
+
8
+ self.readers = []
9
+ self.attributes = []
10
+
6
11
  def empty?
7
12
  as_json.empty?
8
13
  end
9
14
 
10
15
  ## Accessors
11
16
 
12
- def self.model_attr_accessor(*keys)
13
- bools, raws = keys.partition { |it| it.to_s.end_with? '?' }
17
+ def self.model_attr_accessor(*readers)
18
+ bools, raws = readers.partition { |it| it.to_s.end_with? '?' }
14
19
  raw_bools = bools.map { |it| it.to_s[0..-2].to_sym }
15
- keys = raws + raw_bools
20
+ attributes = raws + raw_bools
21
+
22
+ self.readers += readers
23
+ self.attributes += raws + raw_bools
24
+
25
+ define_attr_readers attributes, raw_bools
26
+ define_attr_writers raws, raw_bools
27
+ end
28
+
29
+ # Parses model from an event.
30
+ # Only allowed attributes are accepted
31
+ def self.parse(hash)
32
+ hash ? new(hash.slice(*self.attributes)) : new
33
+ end
16
34
 
17
- define_attr_readers keys, raw_bools
18
- define_attr_writers keys, raw_bools
35
+ def as_json(options = {})
36
+ super(options).slice(*self.class.attributes.map(&:to_s))
37
+ end
19
38
 
20
- # Parses model from an event.
21
- # Only allowed keys are accepted
22
- define_singleton_method :parse do |hash|
23
- hash ? new(hash.slice(*keys)) : new
24
- end
39
+ def self.accessors
40
+ self.readers + self.attributes.map { |it| "#{it}=".to_sym }
25
41
  end
26
42
 
27
43
  # Define the attribute readers for the model,
@@ -11,58 +11,9 @@ module Mumukit::Platform::Organization::Helpers
11
11
  # * theme
12
12
 
13
13
  included do
14
- delegate :theme_stylesheet,
15
- :theme_stylesheet=,
16
- :extension_javascript,
17
- :extension_javascript=, to: :theme
18
-
19
- delegate :login_methods,
20
- :login_methods=,
21
- :login_provider,
22
- :login_provider=,
23
- :provider_settings,
24
- :provider_settings=,
25
- :login_settings,
26
- :feedback_suggestions_enabled?,
27
- :feedback_suggestions_enabled=,
28
- :raise_hand_enabled?,
29
- :raise_hand_enabled=,
30
- :forum_enabled?,
31
- :forum_enabled=,
32
- :report_issue_enabled?,
33
- :report_issue_enabled=,
34
- :public?,
35
- :public=,
36
- :embeddable?,
37
- :embeddable=,
38
- :immersive?,
39
- :immersive=,
40
- :private?, to: :settings
41
-
42
- delegate :logo_url,
43
- :logo_url=,
44
- :banner_url,
45
- :banner_url=,
46
- :open_graph_image_url,
47
- :open_graph_image_url=,
48
- :favicon_url,
49
- :favicon_url=,
50
- :breadcrumb_image_url,
51
- :breadcrumb_image_url=,
52
- :locale,
53
- :locale=,
54
- :locale_json,
55
- :description,
56
- :description=,
57
- :community_link,
58
- :community_link=,
59
- :terms_of_service,
60
- :terms_of_service=,
61
- :contact_email,
62
- :contact_email=,
63
- :errors_explanations,
64
- :errors_explanations=, to: :profile
65
-
14
+ delegate *Mumukit::Platform::Organization::Theme.accessors, to: :theme
15
+ delegate *Mumukit::Platform::Organization::Settings.accessors, :private?, :login_settings, to: :settings
16
+ delegate *Mumukit::Platform::Organization::Profile.accessors, :locale_json, to: :profile
66
17
  end
67
18
 
68
19
  def platform_class_name
@@ -1,7 +1,7 @@
1
1
  class Mumukit::Platform::Organization::Settings < Mumukit::Platform::Model
2
2
  model_attr_accessor :login_methods,
3
3
  :login_provider,
4
- :provider_settings,
4
+ :login_provider_settings,
5
5
  :raise_hand_enabled?,
6
6
  :feedback_suggestions_enabled?,
7
7
  :public?,
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Platform
3
- VERSION = '2.5.0'
3
+ VERSION = '2.6.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: 2.5.0
4
+ version: 2.6.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-09-07 00:00:00.000000000 Z
11
+ date: 2018-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit-nuntius