global_registry_models 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/global_registry_models.gemspec +1 -1
- data/lib/.DS_Store +0 -0
- data/lib/global_registry/subscription.rb +5 -0
- data/lib/global_registry/system_methods.rb +13 -0
- data/lib/global_registry_models/api_operations/finders.rb +2 -1
- data/lib/global_registry_models/api_operations/persistence.rb +26 -10
- data/lib/global_registry_models/api_operations/reset_access_token.rb +11 -0
- data/lib/global_registry_models/api_operations/search.rb +2 -3
- data/lib/global_registry_models/collection.rb +5 -0
- data/lib/global_registry_models/common_base.rb +9 -9
- data/lib/global_registry_models/entity/base.rb +11 -0
- data/lib/global_registry_models/entity_type/base.rb +6 -4
- data/lib/global_registry_models/entity_type/entity_type.rb +5 -1
- data/lib/global_registry_models/entity_type/field.rb +3 -1
- data/lib/global_registry_models/measurement_type/base.rb +4 -0
- data/lib/global_registry_models/measurement_type/measurement_type.rb +4 -2
- data/lib/global_registry_models/relationship_type/base.rb +5 -0
- data/lib/global_registry_models/relationship_type/relationship_type.rb +7 -1
- data/lib/global_registry_models/response_parser.rb +1 -1
- data/lib/global_registry_models/subscription/base.rb +21 -0
- data/lib/global_registry_models/subscription/subscription.rb +17 -0
- data/lib/global_registry_models/system/base.rb +22 -0
- data/lib/global_registry_models/system/system.rb +26 -0
- data/lib/global_registry_models/version.rb +1 -1
- data/lib/global_registry_models.rb +11 -0
- metadata +11 -3
- data/lib/global_registry_models/entity/entity_collection.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32aa339085d76059fde7b418d54786e0b4f8f4f4
|
4
|
+
data.tar.gz: 19c3710e713263f513cff738410b09c81123f8a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7b91626fc49b935df140f14435bbec0dda5f431bb73d5a03109f7dc1d38261c7bb1724d529d453412775296a249e2da5db84b52f5368d5f26355847bebb79e6
|
7
|
+
data.tar.gz: adcab3518d5715d63cc9afd95290433a1a1880f20ef6e00d78fda96225f75fb49490fa1e006b8e1f67826d52a71d64ddb22b454cc6d7cb84bd55b2606c47f041
|
@@ -6,7 +6,7 @@ require 'global_registry_models/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'global_registry_models'
|
8
8
|
spec.version = GlobalRegistryModels::VERSION
|
9
|
-
spec.authors = ['Sheldon Dueck']
|
9
|
+
spec.authors = ['Sheldon Dueck','Daniel Fugere']
|
10
10
|
spec.email = ['sheldon.dueck@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = %q{Data models for the Global Registry.}
|
data/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module GlobalRegistry
|
2
|
+
class System < Base
|
3
|
+
|
4
|
+
def self.reset_access_token(system_id)
|
5
|
+
request(:post, nil, "systems/reset_access_token#{parametrized(system_id)}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.parametrized(system_id)
|
9
|
+
"?id=#{system_id}" if system_id
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -24,7 +24,8 @@ module GlobalRegistryModels
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def find(id)
|
27
|
-
|
27
|
+
response_hash = global_registry_resource.find(id)[ressource_type]
|
28
|
+
response_hash.has_key?(name) ? (new response_hash[name]) : (new response_hash)
|
28
29
|
end
|
29
30
|
|
30
31
|
def page(page_number = 1)
|
@@ -4,12 +4,26 @@ module GlobalRegistryModels
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
module ClassMethods
|
7
|
+
|
8
|
+
def prepare_parameters(object, attributes)
|
9
|
+
attribute_keys = attributes.keys.collect(&:to_sym) & writeable_attributes
|
10
|
+
prepared_attributes = object.attributes.with_indifferent_access.slice(*attribute_keys)
|
11
|
+
prepared_attributes
|
12
|
+
end
|
13
|
+
|
14
|
+
def ressource_type
|
15
|
+
global_registry_resource.to_s.demodulize.underscore
|
16
|
+
end
|
17
|
+
|
7
18
|
def create!(attributes)
|
8
|
-
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
19
|
+
object = new(attributes.with_indifferent_access.except(:id))
|
20
|
+
if object.valid?
|
21
|
+
create_attributes = prepare_parameters(object, attributes)
|
22
|
+
response = global_registry_resource.post(attributes_hash(create_attributes))
|
23
|
+
if response.present?
|
24
|
+
response_hash = response[ressource_type]
|
25
|
+
response_hash.has_key?(name) ? (new response_hash[name]) : (new response_hash)
|
26
|
+
end
|
13
27
|
else
|
14
28
|
raise GlobalRegistryModels::RecordInvalid.new
|
15
29
|
end
|
@@ -22,11 +36,11 @@ module GlobalRegistryModels
|
|
22
36
|
end
|
23
37
|
|
24
38
|
def update!(id, attributes)
|
25
|
-
|
26
|
-
if
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
object = new(attributes)
|
40
|
+
if object.valid?
|
41
|
+
update_attributes = prepare_parameters(object, attributes)
|
42
|
+
response_hash = global_registry_resource.put(id, attributes_hash(update_attributes))[ressource_type]
|
43
|
+
response_hash.has_key?(name) ? (new response_hash[name]) : (new response_hash)
|
30
44
|
else
|
31
45
|
raise GlobalRegistryModels::RecordInvalid.new
|
32
46
|
end
|
@@ -37,6 +51,7 @@ module GlobalRegistryModels
|
|
37
51
|
rescue GlobalRegistryModels::RecordInvalid
|
38
52
|
false
|
39
53
|
end
|
54
|
+
|
40
55
|
end
|
41
56
|
|
42
57
|
def save
|
@@ -52,6 +67,7 @@ module GlobalRegistryModels
|
|
52
67
|
self.class.update! id, { client_integration_id: client_integration_id }.with_indifferent_access.merge(update_attributes)
|
53
68
|
end
|
54
69
|
|
70
|
+
|
55
71
|
end
|
56
72
|
end
|
57
73
|
end
|
@@ -17,10 +17,9 @@ module GlobalRegistryModels
|
|
17
17
|
}).delete_if { |_, v| v.blank? }
|
18
18
|
|
19
19
|
params = clean_params(filters, params)
|
20
|
-
|
21
20
|
response = GlobalRegistryModels::ResponseParser.new(global_registry_resource.get(params))
|
22
|
-
|
23
|
-
|
21
|
+
Collection.new meta: response.meta, list: response.objects
|
22
|
+
|
24
23
|
end
|
25
24
|
|
26
25
|
def clean_params( filters, params )
|
@@ -6,8 +6,10 @@ require 'virtus'
|
|
6
6
|
|
7
7
|
module GlobalRegistryModels
|
8
8
|
class CommonBase
|
9
|
+
|
9
10
|
include ActiveModel::Model
|
10
11
|
include ActiveModel::Validations
|
12
|
+
include ActiveModel::Validations::Callbacks
|
11
13
|
include Virtus.model
|
12
14
|
|
13
15
|
include GlobalRegistryModels::APIOperations::Persistence
|
@@ -15,12 +17,8 @@ module GlobalRegistryModels
|
|
15
17
|
include GlobalRegistryModels::APIOperations::Search
|
16
18
|
include GlobalRegistryModels::APIOperations::Delete
|
17
19
|
|
18
|
-
|
19
20
|
attribute :id, String
|
20
|
-
|
21
|
-
|
22
|
-
validates_presence_of :client_integration_id
|
23
|
-
|
21
|
+
|
24
22
|
def self.title
|
25
23
|
name.titleize
|
26
24
|
end
|
@@ -41,10 +39,12 @@ module GlobalRegistryModels
|
|
41
39
|
attribute_names - [:id]
|
42
40
|
end
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
private
|
43
|
+
|
44
|
+
def underscore_name
|
45
|
+
self.name = self.name.downcase.tr(' ','_') if self.name
|
46
|
+
end
|
48
47
|
|
49
48
|
end
|
49
|
+
|
50
50
|
end
|
@@ -6,6 +6,8 @@
|
|
6
6
|
module GlobalRegistryModels
|
7
7
|
module Entity
|
8
8
|
class Base < CommonBase
|
9
|
+
attribute :client_integration_id, String
|
10
|
+
validates_presence_of :client_integration_id
|
9
11
|
|
10
12
|
def self.search_params
|
11
13
|
{
|
@@ -16,6 +18,15 @@ module GlobalRegistryModels
|
|
16
18
|
def self.global_registry_resource
|
17
19
|
GlobalRegistry::Entity
|
18
20
|
end
|
21
|
+
|
22
|
+
def self.attributes_hash(attributes)
|
23
|
+
{'entity'.to_sym => { name => attributes }}
|
24
|
+
end
|
25
|
+
|
26
|
+
# The name of the entity class. The entity name is required in the api responses and requests, hence the need for this class method.
|
27
|
+
def self.name
|
28
|
+
to_s.gsub(/.*::/, '').underscore
|
29
|
+
end
|
19
30
|
|
20
31
|
end
|
21
32
|
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# A base class providing CRUD for GlobalRegistry Entities.
|
2
|
-
# API doc at https://github.com/CruGlobal/global_registry_docs/wiki/Entities
|
3
|
-
|
4
|
-
|
5
1
|
module GlobalRegistryModels
|
6
2
|
module EntityType
|
7
3
|
class Base < CommonBase
|
@@ -16,6 +12,12 @@ module GlobalRegistryModels
|
|
16
12
|
GlobalRegistry::EntityType
|
17
13
|
end
|
18
14
|
|
15
|
+
def self.attributes_hash(attributes)
|
16
|
+
{
|
17
|
+
'entity_type' => attributes
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -9,6 +9,10 @@ module GlobalRegistryModels
|
|
9
9
|
attribute :data_visibility, String
|
10
10
|
attribute :enum_values, Array
|
11
11
|
attribute :unique_value, Boolean
|
12
|
+
attribute :parent_id, String
|
13
|
+
|
14
|
+
validates_presence_of :name
|
15
|
+
after_validation :underscore_name
|
12
16
|
|
13
17
|
def initialize(params = {})
|
14
18
|
super(params)
|
@@ -25,7 +29,7 @@ module GlobalRegistryModels
|
|
25
29
|
end
|
26
30
|
|
27
31
|
def self.identifying_attributes
|
28
|
-
[:name, :description, :is_editable, :field_type, :data_visibility]
|
32
|
+
[:name, :description, :is_editable, :field_type, :data_visibility, :parent_id]
|
29
33
|
end
|
30
34
|
|
31
35
|
private
|
@@ -6,6 +6,8 @@ module GlobalRegistryModels
|
|
6
6
|
attribute :description, String
|
7
7
|
attribute :is_editable, Boolean
|
8
8
|
attribute :field_type, String
|
9
|
+
attribute :data_visibility, String
|
10
|
+
attribute :parent_id, String
|
9
11
|
|
10
12
|
def initialize(params = {})
|
11
13
|
super(params)
|
@@ -17,7 +19,7 @@ module GlobalRegistryModels
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.identifying_attributes
|
20
|
-
[:name, :description, :is_editable, :field_type]
|
22
|
+
[:name, :description, :is_editable, :field_type, :data_visibility, :parent_id]
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
@@ -9,11 +9,13 @@ module GlobalRegistryModels
|
|
9
9
|
attribute :perm_link, String
|
10
10
|
attribute :unit, String
|
11
11
|
|
12
|
+
validates_presence_of :frequency, :unit, :perm_link, :related_entity_type_id, :name
|
13
|
+
after_validation :underscore_name
|
14
|
+
|
12
15
|
def self.identifying_attributes
|
13
|
-
[:name, :description, :frequency, :perm_link, :unit]
|
16
|
+
[:related_entity_type_id, :name, :description, :frequency, :perm_link, :unit]
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -5,6 +5,7 @@
|
|
5
5
|
module GlobalRegistryModels
|
6
6
|
module RelationshipType
|
7
7
|
class Base < CommonBase
|
8
|
+
validates_presence_of :entity_type1_id, :relationship1, :entity_type2_id, :relationship2
|
8
9
|
|
9
10
|
def self.search_params
|
10
11
|
{}
|
@@ -14,6 +15,10 @@ module GlobalRegistryModels
|
|
14
15
|
GlobalRegistry::RelationshipType
|
15
16
|
end
|
16
17
|
|
18
|
+
def self.attributes_hash(attributes)
|
19
|
+
{ 'relationship_type' => attributes }
|
20
|
+
end
|
21
|
+
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -2,10 +2,16 @@ module GlobalRegistryModels
|
|
2
2
|
module RelationshipType
|
3
3
|
class RelationshipType < Base
|
4
4
|
attribute :id, String
|
5
|
+
attribute :entity_type1_id
|
6
|
+
attribute :entity_type2_id
|
7
|
+
attribute :relationship1
|
8
|
+
attribute :relationship2
|
9
|
+
|
10
|
+
validates_presence_of :entity_type1_id, :relationship1, :entity_type2_id, :relationship2
|
5
11
|
|
6
12
|
def initialize(params = {})
|
7
13
|
super(params)
|
8
|
-
create_involved_types([params["relationship1"],params["relationship2"]]) if params["relationship1"] && params["relationship2"]
|
14
|
+
create_involved_types([params["relationship1"],params["relationship2"]]) if params["relationship1"] && params["relationship2"] && !params["entity_type1_id"]
|
9
15
|
end
|
10
16
|
|
11
17
|
def involved_types
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GlobalRegistryModels
|
2
|
+
module Subscription
|
3
|
+
class Base < CommonBase
|
4
|
+
|
5
|
+
def self.search_params
|
6
|
+
{}
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.global_registry_resource
|
10
|
+
GlobalRegistry::Subscription
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.attributes_hash(attributes)
|
14
|
+
{
|
15
|
+
'subscription' => attributes
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module GlobalRegistryModels
|
2
|
+
module Subscription
|
3
|
+
class Subscription < Base
|
4
|
+
attribute :id, String
|
5
|
+
attribute :entity_type_id, String
|
6
|
+
attribute :endpoint, String
|
7
|
+
attribute :format, String
|
8
|
+
|
9
|
+
validates_presence_of :entity_type_id, :endpoint
|
10
|
+
|
11
|
+
def self.identifying_attributes
|
12
|
+
[:id, :entity_type_id]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module GlobalRegistryModels
|
2
|
+
module System
|
3
|
+
class Base < CommonBase
|
4
|
+
include GlobalRegistryModels::APIOperations::ResetAccessToken
|
5
|
+
|
6
|
+
def self.search_params
|
7
|
+
{}
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.global_registry_resource
|
11
|
+
GlobalRegistry::System
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.attributes_hash(attributes)
|
15
|
+
{
|
16
|
+
'system' => attributes
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module GlobalRegistryModels
|
2
|
+
module System
|
3
|
+
class System < Base
|
4
|
+
attribute :name, String
|
5
|
+
attribute :created_at, DateTime
|
6
|
+
attribute :updated_at, DateTime
|
7
|
+
attribute :contact_name, String
|
8
|
+
attribute :contact_email, String
|
9
|
+
attribute :permalink, String
|
10
|
+
attribute :root, Boolean
|
11
|
+
attribute :access_token, String
|
12
|
+
attribute :trusted_ips, Array
|
13
|
+
|
14
|
+
validates_presence_of :name
|
15
|
+
|
16
|
+
def self.identifying_attributes
|
17
|
+
[:id, :name, :contact_name, :contact_email, :permalink, :trusted_ips]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.identifying_root_attributes
|
21
|
+
[:id, :name, :contact_name, :contact_email, :permalink, :trusted_ips, :root, :access_token]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'active_support/all'
|
2
2
|
|
3
|
+
require 'global_registry/subscription'
|
4
|
+
require 'global_registry/system_methods'
|
5
|
+
|
3
6
|
require 'global_registry_models/version'
|
4
7
|
|
5
8
|
require 'global_registry_models/response_parser'
|
@@ -12,6 +15,8 @@ require 'global_registry_models/api_operations/persistence'
|
|
12
15
|
require 'global_registry_models/api_operations/finders'
|
13
16
|
require 'global_registry_models/api_operations/search'
|
14
17
|
require 'global_registry_models/api_operations/delete'
|
18
|
+
require 'global_registry_models/api_operations/reset_access_token'
|
19
|
+
|
15
20
|
|
16
21
|
require 'global_registry_models/common_base'
|
17
22
|
|
@@ -33,5 +38,11 @@ require 'global_registry_models/relationship_type/involved_type'
|
|
33
38
|
require 'global_registry_models/measurement_type/base'
|
34
39
|
require 'global_registry_models/measurement_type/measurement_type'
|
35
40
|
|
41
|
+
require 'global_registry_models/subscription/base'
|
42
|
+
require 'global_registry_models/subscription/subscription'
|
43
|
+
|
44
|
+
require 'global_registry_models/system/base'
|
45
|
+
require 'global_registry_models/system/system'
|
46
|
+
|
36
47
|
module GlobalRegistryModels
|
37
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global_registry_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheldon Dueck
|
8
|
+
- Daniel Fugere
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
12
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activemodel
|
@@ -141,18 +142,21 @@ files:
|
|
141
142
|
- bin/console
|
142
143
|
- bin/setup
|
143
144
|
- global_registry_models.gemspec
|
145
|
+
- lib/.DS_Store
|
146
|
+
- lib/global_registry/subscription.rb
|
147
|
+
- lib/global_registry/system_methods.rb
|
144
148
|
- lib/global_registry_models.rb
|
145
149
|
- lib/global_registry_models/.DS_Store
|
146
150
|
- lib/global_registry_models/api_operations/delete.rb
|
147
151
|
- lib/global_registry_models/api_operations/finders.rb
|
148
152
|
- lib/global_registry_models/api_operations/persistence.rb
|
153
|
+
- lib/global_registry_models/api_operations/reset_access_token.rb
|
149
154
|
- lib/global_registry_models/api_operations/search.rb
|
150
155
|
- lib/global_registry_models/collection.rb
|
151
156
|
- lib/global_registry_models/common_base.rb
|
152
157
|
- lib/global_registry_models/entity/.DS_Store
|
153
158
|
- lib/global_registry_models/entity/area.rb
|
154
159
|
- lib/global_registry_models/entity/base.rb
|
155
|
-
- lib/global_registry_models/entity/entity_collection.rb
|
156
160
|
- lib/global_registry_models/entity/global_mcc.rb
|
157
161
|
- lib/global_registry_models/entity/iso_country.rb
|
158
162
|
- lib/global_registry_models/entity/ministry.rb
|
@@ -171,6 +175,10 @@ files:
|
|
171
175
|
- lib/global_registry_models/relationship_type/relationship_type.rb
|
172
176
|
- lib/global_registry_models/response_parser.rb
|
173
177
|
- lib/global_registry_models/retryer.rb
|
178
|
+
- lib/global_registry_models/subscription/base.rb
|
179
|
+
- lib/global_registry_models/subscription/subscription.rb
|
180
|
+
- lib/global_registry_models/system/base.rb
|
181
|
+
- lib/global_registry_models/system/system.rb
|
174
182
|
- lib/global_registry_models/version.rb
|
175
183
|
homepage: https://github.com/sheldond/global_registry_models
|
176
184
|
licenses:
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'csv'
|
2
|
-
|
3
|
-
module GlobalRegistryModels
|
4
|
-
class EntityCollection < Collection
|
5
|
-
include Enumerable
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
def_delegators :list, :[], :size, :concat, :blank?, :present?
|
9
|
-
|
10
|
-
def initialize(meta:, list:)
|
11
|
-
@meta = meta
|
12
|
-
@list = list
|
13
|
-
end
|
14
|
-
|
15
|
-
def each
|
16
|
-
@entities.each { |entity| yield entity }
|
17
|
-
end
|
18
|
-
|
19
|
-
def all
|
20
|
-
@entities
|
21
|
-
end
|
22
|
-
|
23
|
-
def page
|
24
|
-
@meta['page']
|
25
|
-
end
|
26
|
-
|
27
|
-
def last_page?
|
28
|
-
!@meta['next_page']
|
29
|
-
end
|
30
|
-
|
31
|
-
def first_page?
|
32
|
-
page == 1
|
33
|
-
end
|
34
|
-
|
35
|
-
def next_page
|
36
|
-
last_page? ? nil : page + 1
|
37
|
-
end
|
38
|
-
|
39
|
-
def prev_page
|
40
|
-
first_page? ? nil : page - 1
|
41
|
-
end
|
42
|
-
|
43
|
-
def from
|
44
|
-
@meta['from']
|
45
|
-
end
|
46
|
-
|
47
|
-
def to
|
48
|
-
@meta['to']
|
49
|
-
end
|
50
|
-
|
51
|
-
def per
|
52
|
-
(to - from) + 1
|
53
|
-
end
|
54
|
-
|
55
|
-
def to_csv
|
56
|
-
CSV.generate do |csv|
|
57
|
-
attributes = @entities.first.attributes.collect(&:first).sort
|
58
|
-
csv << attributes
|
59
|
-
@entities.each do |entity|
|
60
|
-
csv << attributes.collect { |attribute| entity.attributes[attribute] }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|