gnoso-remote_entity 0.0.2 → 0.0.3
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.
- data/lib/remote_entity/entity_resource.rb +14 -8
- metadata +1 -1
@@ -4,10 +4,8 @@ module RemoteEntity
|
|
4
4
|
class EntityResource < ActiveResource::Base
|
5
5
|
|
6
6
|
def initialize(attrs = {})
|
7
|
-
@@schema ||= []
|
8
|
-
|
9
7
|
attrs = HashWithIndifferentAccess.new(attrs)
|
10
|
-
|
8
|
+
self.class.get_schema.each do |attribute|
|
11
9
|
if !attrs.has_key?(attribute)
|
12
10
|
attrs[attribute] = nil
|
13
11
|
end
|
@@ -22,27 +20,32 @@ module RemoteEntity
|
|
22
20
|
# Defines methods for the following properties on every instance of this
|
23
21
|
# type that is created
|
24
22
|
def self.schema(*args)
|
25
|
-
|
23
|
+
@schema = args
|
26
24
|
end
|
27
25
|
|
28
26
|
# Helps us set the site automatically.
|
29
27
|
def self.version=(version)
|
30
|
-
|
28
|
+
@api_version = version
|
31
29
|
self.update_site
|
32
30
|
end
|
33
31
|
|
34
32
|
def self.version
|
35
|
-
return defined?(
|
33
|
+
return defined?(@api_version) ? @api_version : nil
|
36
34
|
end
|
37
35
|
|
38
36
|
# Helps us set the site automatically
|
39
37
|
def self.service=(service)
|
40
|
-
|
38
|
+
@service = service
|
41
39
|
self.update_site
|
42
40
|
end
|
43
41
|
|
44
42
|
def self.service
|
45
|
-
return defined?(
|
43
|
+
return defined?(@service) ? @service : nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.site
|
47
|
+
self.update_site
|
48
|
+
super
|
46
49
|
end
|
47
50
|
|
48
51
|
private
|
@@ -56,5 +59,8 @@ module RemoteEntity
|
|
56
59
|
self.password = ""
|
57
60
|
end
|
58
61
|
end
|
62
|
+
def self.get_schema
|
63
|
+
@schema || []
|
64
|
+
end
|
59
65
|
end
|
60
66
|
end
|