megam_api 0.100 → 1.5.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -69
  3. data/lib/megam/api.rb +15 -37
  4. data/lib/megam/api/errors.rb +19 -19
  5. data/lib/megam/api/version.rb +1 -1
  6. data/lib/megam/core/account.rb +1 -1
  7. data/lib/megam/core/assemblies.rb +1 -1
  8. data/lib/megam/core/assemblies_collection.rb +7 -15
  9. data/lib/megam/core/assembly.rb +1 -1
  10. data/lib/megam/core/assembly_collection.rb +7 -15
  11. data/lib/megam/core/balances.rb +1 -1
  12. data/lib/megam/core/balances_collection.rb +8 -16
  13. data/lib/megam/core/billedhistories.rb +1 -1
  14. data/lib/megam/core/billedhistories_collection.rb +7 -15
  15. data/lib/megam/core/components.rb +1 -1
  16. data/lib/megam/core/components_collection.rb +103 -110
  17. data/lib/megam/core/domain_collection.rb +102 -109
  18. data/lib/megam/core/domains.rb +1 -1
  19. data/lib/megam/core/error.rb +1 -15
  20. data/lib/megam/core/json_compat.rb +170 -208
  21. data/lib/megam/core/marketplace.rb +1 -1
  22. data/lib/megam/core/marketplace_collection.rb +7 -16
  23. data/lib/megam/core/organizations.rb +1 -1
  24. data/lib/megam/core/organizations_collection.rb +8 -40
  25. data/lib/megam/core/promos.rb +1 -1
  26. data/lib/megam/core/request.rb +1 -1
  27. data/lib/megam/core/request_collection.rb +7 -16
  28. data/lib/megam/core/rest_adapter.rb +54 -0
  29. data/lib/megam/core/sensors.rb +1 -1
  30. data/lib/megam/core/sensors_collection.rb +7 -14
  31. data/lib/megam/core/sshkey.rb +1 -1
  32. data/lib/megam/core/sshkey_collection.rb +103 -110
  33. data/lib/megam/core/stuff.rb +2 -34
  34. data/lib/megam/core/text.rb +1 -0
  35. data/lib/megam/core/text_formatter.rb +2 -1
  36. data/megam_api.gemspec +2 -2
  37. metadata +10 -56
  38. data/lib/megam/api/availableunits.rb +0 -50
  39. data/lib/megam/api/billings.rb +0 -50
  40. data/lib/megam/api/credithistories.rb +0 -50
  41. data/lib/megam/api/csars.rb +0 -75
  42. data/lib/megam/api/discounts.rb +0 -50
  43. data/lib/megam/api/invoices.rb +0 -50
  44. data/lib/megam/api/login.rb +0 -29
  45. data/lib/megam/api/subscriptions.rb +0 -50
  46. data/lib/megam/core/auth.rb +0 -91
  47. data/lib/megam/core/availableunits.rb +0 -182
  48. data/lib/megam/core/availableunits_collection.rb +0 -144
  49. data/lib/megam/core/billings.rb +0 -242
  50. data/lib/megam/core/billings_collection.rb +0 -144
  51. data/lib/megam/core/config.rb +0 -41
  52. data/lib/megam/core/credithistories.rb +0 -191
  53. data/lib/megam/core/credithistories_collection.rb +0 -144
  54. data/lib/megam/core/csar.rb +0 -179
  55. data/lib/megam/core/csar_collection.rb +0 -148
  56. data/lib/megam/core/discounts.rb +0 -204
  57. data/lib/megam/core/discounts_collection.rb +0 -164
  58. data/lib/megam/core/invoices.rb +0 -231
  59. data/lib/megam/core/invoices_collection.rb +0 -144
  60. data/lib/megam/core/server_api.rb +0 -52
  61. data/lib/megam/core/subscriptions.rb +0 -191
  62. data/lib/megam/core/subscriptions_collection.rb +0 -144
  63. data/test/test_availableunits.rb +0 -28
  64. data/test/test_billings.rb +0 -33
  65. data/test/test_cat_requests.rb +0 -20
  66. data/test/test_credithistories.rb +0 -29
  67. data/test/test_csars.rb +0 -22
  68. data/test/test_discounts.rb +0 -31
  69. data/test/test_invoices.rb +0 -31
  70. data/test/test_login.rb +0 -10
  71. data/test/test_marketplaceaddons.rb +0 -46
  72. data/test/test_predefclouds.rb +0 -80
  73. data/test/test_subscriptions.rb +0 -29
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class Domains < Megam::ServerAPI
17
+ class Domains < Megam::RestAdapter
18
18
  def initialize(o)
19
19
  @id = nil
20
20
  @org_id = nil
@@ -15,19 +15,11 @@
15
15
  #
16
16
  module Megam
17
17
  class Error
18
-
18
+
19
19
  def initialize
20
20
  @some_msg = {}
21
21
  end
22
22
 
23
- #used by resque workers and any other background job
24
- def auth
25
- self
26
- end
27
-
28
- def megam_rest
29
- Megam::Scm.new(Megam::Config[:name], Megam::Config[:displayName], Megam::Config[:mail], Megam::Config[:password])
30
- end
31
23
 
32
24
  def some_msg(arg=nil)
33
25
  if arg != nil
@@ -84,12 +76,6 @@ module Megam
84
76
  self
85
77
  end
86
78
 
87
- # just an auth
88
- def self.auth
89
- megam_rest.post_auth
90
- self
91
- end
92
-
93
79
 
94
80
  def to_s
95
81
  Megam::Stuff.styled_hash(to_hash)
@@ -13,216 +13,178 @@
13
13
 
14
14
  # Wrapper class for interacting with JSON.
15
15
 
16
- require 'yajl/json_gem'
17
- require 'yajl'
16
+ require "ffi_yajl"
17
+ # We're requiring this to prevent breaking consumers using Hash.to_json
18
+ require "json"
18
19
 
19
20
  module Megam
20
- class JSONCompat
21
- JSON_MAX_NESTING = 1000
22
-
23
-
24
- JSON_CLAZ = 'json_claz'.freeze
25
-
26
- MEGAM_ACCOUNT = 'Megam::Account'.freeze
27
- MEGAM_ASSEMBLIES = 'Megam::Assemblies'.freeze
28
- MEGAM_ASSEMBLIESCOLLECTION = 'Megam::AssembliesCollection'.freeze
29
- MEGAM_ASSEMBLY = 'Megam::Assembly'.freeze
30
- MEGAM_ASSEMBLYCOLLECTION = 'Megam::AssemblyCollection'.freeze
31
- MEGAM_AUTH = 'Megam::Auth'.freeze
32
- MEGAM_AVAILABLEUNITS = 'Megam::Availableunits'.freeze
33
- MEGAM_AVAILABLEUNITSCOLLECTION = 'Megam::AvailableunitsCollection'.freeze
34
- MEGAM_BALANCES = 'Megam::Balances'.freeze
35
- MEGAM_BALANCESCOLLECTION = 'Megam::BalancesCollection'.freeze
36
- MEGAM_BILLEDHISTORIES = 'Megam::Billedhistories'.freeze
37
- MEGAM_BILLEDHISTORIESCOLLECTION = 'Megam::BilledhistoriesCollection'.freeze
38
- MEGAM_BILLINGS = 'Megam::Billings'.freeze
39
- MEGAM_BILLINGSCOLLECTION = 'Megam::BillingsCollection'.freeze
40
- MEGAM_COMPONENTS = 'Megam::Components'.freeze
41
- MEGAM_COMPONENTSCOLLECTION = 'Megam::ComponentsCollection'.freeze
42
- MEGAM_CREDITHISTORIES = 'Megam::Credithistories'.freeze
43
- MEGAM_CREDITHISTORIESCOLLECTION = 'Megam::CredithistoriesCollection'.freeze
44
- MEGAM_CSAR = 'Megam::CSAR'.freeze
45
- MEGAM_CSARCOLLECTION = 'Megam::CSARCollection'.freeze
46
- MEGAM_DOMAIN = 'Megam::Domains'.freeze
47
- MEGAM_DOMAINCOLLECTION = 'Megam::DomainsCollection'.freeze
48
- MEGAM_DISCOUNTS = 'Megam::Discounts'.freeze
49
- MEGAM_DISCOUNTSCOLLECTION = 'Megam::DiscountsCollection'.freeze
50
- MEGAM_ERROR = 'Megam::Error'.freeze
51
- MEGAM_INVOICESCOLLECTION = 'Megam::InvoicesCollection'.freeze
52
- MEGAM_INVOICES = 'Megam::Invoices'.freeze
53
- MEGAM_MARKETPLACE = 'Megam::MarketPlace'.freeze
54
- MEGAM_MARKETPLACECOLLECTION = 'Megam::MarketPlaceCollection'.freeze
55
- MEGAM_ORGANIZATION = 'Megam::Organizations'.freeze
56
- MEGAM_ORGANIZATIONSCOLLECTION = 'Megam::OrganizationsCollection'.freeze
57
- MEGAM_REQUEST = 'Megam::Request'.freeze
58
- MEGAM_REQUESTCOLLECTION = 'Megam::RequestCollection'.freeze
59
- MEGAM_SENSORS = 'Megam::Sensors'.freeze
60
- MEGAM_SENSORSCOLLECTION = 'Megam::SensorsCollection'.freeze
61
- MEGAM_SSHKEY = 'Megam::SshKey'.freeze
62
- MEGAM_SSHKEYCOLLECTION = 'Megam::SshKeyCollection'.freeze
63
- MEGAM_SUBSCRIPTIONS = 'Megam::Subscriptions'.freeze
64
- MEGAM_SUBSCRIPTIONSCOLLECTION = 'Megam::SubscriptionsCollection'.freeze
65
- MEGAM_PROMOS = 'Megam::Promos'.freeze
66
-
67
- class <<self
68
- # Increase the max nesting for JSON, which defaults
69
- # to 19, and isn't enough for some (for example, a Node within a Node)
70
- # structures.
71
- def opts_add_max_nesting(opts)
72
- if opts.nil? || !opts.key?(:max_nesting)
73
- opts = opts.nil? ? {} : opts.clone
74
- opts[:max_nesting] = JSON_MAX_NESTING
21
+ class JSONCompat
22
+ JSON_MAX_NESTING = 1000
23
+
24
+
25
+ JSON_CLAZ = 'json_claz'.freeze
26
+
27
+ MEGAM_ACCOUNT = 'Megam::Account'.freeze
28
+ MEGAM_ASSEMBLIES = 'Megam::Assemblies'.freeze
29
+ MEGAM_ASSEMBLIESCOLLECTION = 'Megam::AssembliesCollection'.freeze
30
+ MEGAM_ASSEMBLY = 'Megam::Assembly'.freeze
31
+ MEGAM_ASSEMBLYCOLLECTION = 'Megam::AssemblyCollection'.freeze
32
+ MEGAM_BALANCES = 'Megam::Balances'.freeze
33
+ MEGAM_BALANCESCOLLECTION = 'Megam::BalancesCollection'.freeze
34
+ MEGAM_BILLEDHISTORIES = 'Megam::Billedhistories'.freeze
35
+ MEGAM_BILLEDHISTORIESCOLLECTION = 'Megam::BilledhistoriesCollection'.freeze
36
+ MEGAM_COMPONENTS = 'Megam::Components'.freeze
37
+ MEGAM_COMPONENTSCOLLECTION = 'Megam::ComponentsCollection'.freeze
38
+ MEGAM_DOMAIN = 'Megam::Domains'.freeze
39
+ MEGAM_DOMAINCOLLECTION = 'Megam::DomainsCollection'.freeze
40
+ MEGAM_ERROR = 'Megam::Error'.freeze
41
+ MEGAM_MARKETPLACE = 'Megam::MarketPlace'.freeze
42
+ MEGAM_MARKETPLACECOLLECTION = 'Megam::MarketPlaceCollection'.freeze
43
+ MEGAM_ORGANIZATION = 'Megam::Organizations'.freeze
44
+ MEGAM_ORGANIZATIONSCOLLECTION = 'Megam::OrganizationsCollection'.freeze
45
+ MEGAM_REQUEST = 'Megam::Request'.freeze
46
+ MEGAM_REQUESTCOLLECTION = 'Megam::RequestCollection'.freeze
47
+ MEGAM_SENSORS = 'Megam::Sensors'.freeze
48
+ MEGAM_SENSORSCOLLECTION = 'Megam::SensorsCollection'.freeze
49
+ MEGAM_SSHKEY = 'Megam::SshKey'.freeze
50
+ MEGAM_SSHKEYCOLLECTION = 'Megam::SshKeyCollection'.freeze
51
+ MEGAM_PROMOS = 'Megam::Promos'.freeze
52
+
53
+ class <<self
54
+ # API to use to avoid create_addtions
55
+ def parse(source, opts = {})
56
+ begin
57
+ FFI_Yajl::Parser.parse(source, opts)
58
+ rescue FFI_Yajl::ParseError => e
59
+ raise JSON::ParseError, e.message
60
+ end
61
+ end
62
+
63
+ # Just call the JSON gem's parse method with a modified :max_nesting field
64
+ def from_json(source, opts = {})
65
+ obj = parse(source, opts)
66
+
67
+ # JSON gem requires top level object to be a Hash or Array (otherwise
68
+ # you get the "must contain two octets" error). Yajl doesn't impose the
69
+ # same limitation. For compatibility, we re-impose this condition.
70
+ unless obj.kind_of?(Hash) || obj.kind_of?(Array)
71
+ raise JSON::ParseError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})"
72
+ end
73
+
74
+ # The old default in the json gem (which we are mimicing because we
75
+ # sadly rely on this misfeature) is to "create additions" i.e., convert
76
+ # JSON objects into ruby objects. Explicit :create_additions => false
77
+ # is required to turn it off.
78
+ if opts[:create_additions].nil? || opts[:create_additions]
79
+ map_to_rb_obj(obj)
80
+ else
81
+ obj
82
+ end
83
+ end
84
+
85
+ # Look at an object that's a basic type (from json parse) and convert it
86
+ # to an instance of Chef classes if desired.
87
+ def map_to_rb_obj(json_obj)
88
+ case json_obj
89
+ when Hash
90
+ mapped_hash = map_hash_to_rb_obj(json_obj)
91
+ if json_obj.has_key?(JSON_CLAZ) && (class_to_inflate = class_for_json_class(json_obj[JSON_CLAZ]))
92
+ class_to_inflate.json_create(mapped_hash)
93
+ else
94
+ mapped_hash
95
+ end
96
+ when Array
97
+ json_obj.map { |e| map_to_rb_obj(e) }
98
+ else
99
+ json_obj
100
+ end
101
+ end
102
+
103
+ def map_hash_to_rb_obj(json_hash)
104
+ json_hash.each do |key, value|
105
+ json_hash[key] = map_to_rb_obj(value)
106
+ end
107
+ json_hash
108
+ end
109
+
110
+ def to_json(obj, opts = nil)
111
+ begin
112
+ FFI_Yajl::Encoder.encode(obj, opts)
113
+ rescue FFI_Yajl::EncodeError => e
114
+ raise JSON::GeneratorError, e.message
115
+ end
116
+ end
117
+
118
+
119
+ def to_json_pretty(obj, opts = nil)
120
+ opts ||= {}
121
+ options_map = {}
122
+ options_map[:pretty] = true
123
+ options_map[:indent] = opts[:indent] if opts.has_key?(:indent)
124
+ to_json(obj, options_map).chomp
125
+ end
126
+
127
+
128
+ # Map +JSON_CLAZ+ to a Class object. We use a +case+ instead of a Hash
129
+ # assigned to a constant because otherwise this file could not be loaded
130
+ # until all the constants were defined, which means you'd have to load
131
+ # the world to get json.
132
+ def class_for_json_class(json_class)
133
+ case json_class
134
+ when MEGAM_ERROR
135
+ Megam::Error
136
+ when MEGAM_ACCOUNT
137
+ Megam::Account
138
+ when MEGAM_ASSEMBLIES
139
+ Megam::Assemblies
140
+ when MEGAM_ASSEMBLIESCOLLECTION
141
+ Megam::AssembliesCollection
142
+ when MEGAM_ASSEMBLY
143
+ Megam::Assembly
144
+ when MEGAM_ASSEMBLYCOLLECTION
145
+ Megam::AssemblyCollection
146
+ when MEGAM_COMPONENTS
147
+ Megam::Components
148
+ when MEGAM_COMPONENTSCOLLECTION
149
+ Megam::ComponentsCollection
150
+ when MEGAM_REQUEST
151
+ Megam::Request
152
+ when MEGAM_REQUESTCOLLECTION
153
+ Megam::RequestCollection
154
+ when MEGAM_SSHKEY
155
+ Megam::SshKey
156
+ when MEGAM_SSHKEYCOLLECTION
157
+ Megam::SshKeyCollection
158
+ when MEGAM_MARKETPLACE
159
+ Megam::MarketPlace
160
+ when MEGAM_MARKETPLACECOLLECTION
161
+ Megam::MarketPlaceCollection
162
+ when MEGAM_ORGANIZATION
163
+ Megam::Organizations
164
+ when MEGAM_ORGANIZATIONSCOLLECTION
165
+ Megam::OrganizationsCollection
166
+ when MEGAM_DOMAIN
167
+ Megam::Domains
168
+ when MEGAM_DOMAINCOLLECTION
169
+ Megam::DomainsCollection
170
+ when MEGAM_SENSORS
171
+ Megam::Sensors
172
+ when MEGAM_SENSORSCOLLECTION
173
+ Megam::SensorsCollection
174
+ when MEGAM_BALANCES
175
+ Megam::Balances
176
+ when MEGAM_BALANCESCOLLECTION
177
+ Megam::BalancesCollection
178
+ when MEGAM_BILLEDHISTORIES
179
+ Megam::Billedhistories
180
+ when MEGAM_BILLEDHISTORIESCOLLECTION
181
+ Megam::BilledhistoriesCollection
182
+ when MEGAM_PROMOS
183
+ Megam::Promos
184
+ else
185
+ fail JSON::ParserError, "Unsupported `json_class` type '#{json_class}'"
186
+ end
187
+ end
75
188
  end
76
- opts
77
- end
78
-
79
- # Just call the JSON gem's parse method with a modified :max_nesting field
80
- def from_json(source, opts = {})
81
- obj = ::Yajl::Parser.parse(source)
82
-
83
- # JSON gem requires top level object to be a Hash or Array (otherwise
84
- # you get the "must contain two octets" error). Yajl doesn't impose the
85
- # same limitation. For compatibility, we re-impose this condition.
86
- unless obj.is_a?(Hash) || obj.is_a?(Array)
87
- fail JSON::ParserError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})"
88
- end
89
-
90
- # The old default in the json gem (which we are mimicing because we
91
- # sadly rely on this misfeature) is to "create additions" i.e., convert
92
- # JSON objects into ruby objects. Explicit :create_additions => false
93
- # is required to turn it off.
94
- if opts[:create_additions].nil? || opts[:create_additions]
95
- map_to_rb_obj(obj)
96
- else
97
- obj
98
- end
99
- end
100
-
101
- # Look at an object that's a basic type (from json parse) and convert it
102
- # to an instance of Megam classes if desired.
103
- def map_to_rb_obj(json_obj)
104
- case json_obj
105
- when Hash
106
- mapped_hash = map_hash_to_rb_obj(json_obj)
107
-
108
- if json_obj.key?(JSON_CLAZ) && (class_to_inflate = class_for_json_class(json_obj[JSON_CLAZ]))
109
- class_to_inflate.json_create(mapped_hash)
110
-
111
- else
112
- mapped_hash
113
- end
114
- when Array
115
- json_obj.map { |e| map_to_rb_obj(e) }
116
- else
117
- json_obj
118
- end
119
- end
120
-
121
- def map_hash_to_rb_obj(json_hash)
122
- json_hash.each do |key, value|
123
- json_hash[key] = map_to_rb_obj(value)
124
- end
125
- json_hash
126
- end
127
-
128
- def to_json(obj, opts = nil)
129
- obj.to_json(opts_add_max_nesting(opts))
130
- end
131
-
132
- def to_json_pretty(obj, opts = nil)
133
- ::JSON.pretty_generate(obj, opts_add_max_nesting(opts))
134
- end
135
-
136
- # Map +JSON_CLAZ+ to a Class object. We use a +case+ instead of a Hash
137
- # assigned to a constant because otherwise this file could not be loaded
138
- # until all the constants were defined, which means you'd have to load
139
- # the world to get json.
140
- def class_for_json_class(json_class)
141
- case json_class
142
- when MEGAM_ERROR
143
- Megam::Error
144
- when MEGAM_AUTH
145
- Megam::Auth
146
- when MEGAM_ACCOUNT
147
- Megam::Account
148
- when MEGAM_ASSEMBLIES
149
- Megam::Assemblies
150
- when MEGAM_ASSEMBLIESCOLLECTION
151
- Megam::AssembliesCollection
152
- when MEGAM_ASSEMBLY
153
- Megam::Assembly
154
- when MEGAM_ASSEMBLYCOLLECTION
155
- Megam::AssemblyCollection
156
- when MEGAM_COMPONENTS
157
- Megam::Components
158
- when MEGAM_COMPONENTSCOLLECTION
159
- Megam::ComponentsCollection
160
- when MEGAM_REQUEST
161
- Megam::Request
162
- when MEGAM_REQUESTCOLLECTION
163
- Megam::RequestCollection
164
- when MEGAM_SSHKEY
165
- Megam::SshKey
166
- when MEGAM_SSHKEYCOLLECTION
167
- Megam::SshKeyCollection
168
- when MEGAM_MARKETPLACE
169
- Megam::MarketPlace
170
- when MEGAM_MARKETPLACECOLLECTION
171
- Megam::MarketPlaceCollection
172
- when MEGAM_ORGANIZATION
173
- Megam::Organizations
174
- when MEGAM_ORGANIZATIONSCOLLECTION
175
- Megam::OrganizationsCollection
176
- when MEGAM_CSAR
177
- Megam::CSAR
178
- when MEGAM_CSARCOLLECTION
179
- Megam::CSARCollection
180
- when MEGAM_DOMAIN
181
- Megam::Domains
182
- when MEGAM_DOMAINCOLLECTION
183
- Megam::DomainsCollection
184
- when MEGAM_SENSORS
185
- Megam::Sensors
186
- when MEGAM_SENSORSCOLLECTION
187
- Megam::SensorsCollection
188
- when MEGAM_AVAILABLEUNITS
189
- Megam::Availableunits
190
- when MEGAM_AVAILABLEUNITSCOLLECTION
191
- Megam::AvailableunitsCollection
192
- when MEGAM_BALANCES
193
- Megam::Balances
194
- when MEGAM_BALANCESCOLLECTION
195
- Megam::BalancesCollection
196
- when MEGAM_BILLEDHISTORIES
197
- Megam::Billedhistories
198
- when MEGAM_BILLEDHISTORIESCOLLECTION
199
- Megam::BilledhistoriesCollection
200
- when MEGAM_INVOICES
201
- Megam::Invoices
202
- when MEGAM_INVOICESCOLLECTION
203
- Megam::InvoicesCollection
204
- when MEGAM_BILLINGS
205
- Megam::Billings
206
- when MEGAM_BILLINGSCOLLECTION
207
- Megam::BillingsCollection
208
- when MEGAM_CREDITHISTORIES
209
- Megam::Credithistories
210
- when MEGAM_CREDITHISTORIESCOLLECTION
211
- Megam::CredithistoriesCollection
212
- when MEGAM_DISCOUNTS
213
- Megam::Discounts
214
- when MEGAM_DISCOUNTSCOLLECTION
215
- Megam::DiscountsCollection
216
- when MEGAM_SUBSCRIPTIONS
217
- Megam::Subscriptions
218
- when MEGAM_SUBSCRIPTIONSCOLLECTION
219
- Megam::SubscriptionsCollection
220
- when MEGAM_PROMOS
221
- Megam::Promos
222
- else
223
- fail JSON::ParserError, "Unsupported `json_class` type '#{json_class}'"
224
- end
225
- end
226
189
  end
227
- end
228
190
  end
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
  module Megam
19
- class MarketPlace < Megam::ServerAPI
19
+ class MarketPlace < Megam::RestAdapter
20
20
  def initialize(o)
21
21
  @id = nil
22
22
  @settings_name = nil
@@ -101,21 +101,17 @@ module Megam
101
101
  @apps[res]
102
102
  end
103
103
 
104
- # Transform the ruby obj -> to a Hash
105
- def to_hash
106
- index_hash = Hash.new
107
- self.each do |app|
108
- index_hash[app.flavor] = app.to_s
109
- end
110
- index_hash
104
+ def to_s
105
+ @apps.join(", ")
111
106
  end
112
107
 
113
- # Serialize this object as a hash: called from JsonCompat.
114
- # Verify if this called from JsonCompat during testing.
115
- def to_json(*a)
116
- for_json.to_json(*a)
108
+ def for_json
109
+ to_a.map { |item| item.to_s }
117
110
  end
118
111
 
112
+ def to_json(*a)
113
+ Megam::JSONCompat.to_json(for_json, *a)
114
+ end
119
115
 
120
116
  def self.json_create(o)
121
117
  collection = self.new()
@@ -138,10 +134,5 @@ module Megam
138
134
  end
139
135
  true
140
136
  end
141
-
142
- def to_s
143
- Megam::Stuff.styled_hash(to_hash)
144
- end
145
-
146
137
  end
147
138
  end