widgets_api_client 0.1.0.8 → 0.1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/lib/domain/widget.rb +23 -40
- data/lib/domain/widget_base.rb +12 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f6395196c2b2e74cc6bb7aa6f4557b286c7bd95
|
4
|
+
data.tar.gz: a3df4113899f7d1e8679cad877d61a377d52895a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f2b42a73ca1f7acbe201f987ada7ca9ad9a9ddbdd6b73cf90723e8f2edb7d25a0e6fb63315a846d854cf00266d60c97e71f615ad076a522fde1aff710903896
|
7
|
+
data.tar.gz: 540b8708fd3c9b9f15f668db4645a55d19fcf7e866a9e21ca62a12b461a26cd1e7880b3d8f7438caf31016d5665722efd9d269589bbe4e123a5fd4f49f84e663
|
data/Gemfile
CHANGED
@@ -3,9 +3,6 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
3
3
|
gem 'rspec', :require => 'spec'
|
4
4
|
gem 'rest-client'
|
5
5
|
gem 'json'
|
6
|
-
gem 'activemodel'
|
7
|
-
gem 'activemodel-serializers-xml'
|
8
|
-
gem 'active_model_serializers'
|
9
6
|
|
10
7
|
group :test do
|
11
8
|
gem 'simplecov', require: false
|
data/lib/domain/widget.rb
CHANGED
@@ -1,51 +1,34 @@
|
|
1
1
|
require 'json'
|
2
|
-
|
3
|
-
#
|
4
|
-
# Widget model conatining widget craeate and update attributes
|
5
|
-
#
|
6
2
|
class Widget
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
attr_accessor :name
|
4
|
+
attr_accessor :description
|
5
|
+
attr_accessor :kind
|
10
6
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# @param [String] description
|
16
|
-
# @param [String] kind Kind of widget - hidden/visible
|
17
|
-
#
|
18
|
-
def initialize(name: nil, description: nil, kind: nil)
|
19
|
-
self.name = name
|
20
|
-
self.description = description
|
21
|
-
self.kind = kind
|
22
|
-
end
|
7
|
+
def initialize name: nil, description: nil, kind: nil
|
8
|
+
self.name, self.description, self.kind =
|
9
|
+
name, description, kind
|
10
|
+
end
|
23
11
|
|
24
|
-
|
25
|
-
|
26
|
-
#
|
27
|
-
# @param [refrence] *data widget object refrence
|
28
|
-
#
|
29
|
-
# @return [<Type>] Json represenatation of widget object
|
30
|
-
#
|
31
|
-
def to_json(*data)
|
32
|
-
hash = {
|
12
|
+
def to_json(*a)
|
13
|
+
hash = {
|
33
14
|
name: @name,
|
34
15
|
description: @description,
|
35
16
|
kind: @kind
|
36
|
-
}
|
37
|
-
hash.delete_if { |k, v| v.nil? }
|
38
|
-
hash.to_json(*
|
17
|
+
}
|
18
|
+
hash.delete_if { |k, v| v.nil? || v.empty? }
|
19
|
+
hash.to_json(*a)
|
39
20
|
end
|
40
21
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
22
|
+
def self.json_create(o)
|
23
|
+
b_from_json = new
|
24
|
+
b_from_json.name = o['name']
|
25
|
+
b_from_json.description = o['description']
|
26
|
+
b_from_json.kind = o['kind']
|
27
|
+
b_from_json
|
28
|
+
end
|
29
|
+
|
48
30
|
def self.get_payload(widget)
|
49
|
-
widget.to_json
|
31
|
+
return widget.to_json
|
50
32
|
end
|
51
|
-
|
33
|
+
|
34
|
+
end
|
data/lib/domain/widget_base.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
require 'json'
|
2
|
-
|
3
|
-
#
|
4
|
-
# Widget Base class containing widget object
|
5
|
-
#
|
6
2
|
class WidgetBase
|
7
|
-
|
3
|
+
attr_accessor :widget
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}.to_json(*data)
|
5
|
+
def to_json(*a)
|
6
|
+
{
|
7
|
+
widget: @widget
|
8
|
+
}.to_json(*a)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.json_create(o)
|
12
|
+
a_from_json = new
|
13
|
+
a_from_json.widget = o['widget']
|
14
|
+
a_from_json
|
20
15
|
end
|
21
|
-
end
|
16
|
+
end
|