pack_api 1.0.5 → 1.0.6
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60e98dc35dc970a330d8389e332c79e0b88a0286260603f1a06607be9aeae8f8
|
|
4
|
+
data.tar.gz: 8f5293317ca533dfa471394a47967eb8a8d3af568e1d3f27fe544cd9251c304b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff0d306e37c0e1bd186cad1c71bfe992c41f22f9f2717aa4072b70734e4a1ad867af985e8732085eb1c8e2a3410ec9cc39a62496e62e26b5bf1816245b9cf79e
|
|
7
|
+
data.tar.gz: 339a131ff33b1e817d1c18b7ac1ca948a5bc3355837d90f4f9b7a8596da88a0452decacbf518d23f525f27a91cc44d8c23e100dcf1b5c6753cbdd0a409d8b7dd
|
|
@@ -35,7 +35,7 @@ module PackAPI::Mapping
|
|
|
35
35
|
|
|
36
36
|
# prevent api_attributes from being used unless they are in the public type definition
|
|
37
37
|
unless mappings.key?(api_attribute)
|
|
38
|
-
raise
|
|
38
|
+
raise PackAPI::InternalError.new("unknown attribute '#{api_attribute}' for #{@model_type.name}.")
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
mappings[api_attribute]
|
|
@@ -9,6 +9,7 @@ module PackAPI::Mapping
|
|
|
9
9
|
super
|
|
10
10
|
@optional_attributes_to_include = nil
|
|
11
11
|
@model_attributes_of_interest = nil
|
|
12
|
+
@api_attributes_of_interest = nil
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def execute
|
|
@@ -23,6 +24,10 @@ module PackAPI::Mapping
|
|
|
23
24
|
|
|
24
25
|
protected
|
|
25
26
|
|
|
27
|
+
def api_attribute_names
|
|
28
|
+
api_attributes_of_interest || api_type.attribute_names
|
|
29
|
+
end
|
|
30
|
+
|
|
26
31
|
def include_api_attribute?(api_attribute)
|
|
27
32
|
!optional_api_attribute?(api_attribute) || include_optional_api_attribute?(api_attribute)
|
|
28
33
|
end
|
|
@@ -31,6 +36,10 @@ module PackAPI::Mapping
|
|
|
31
36
|
@model_attributes_of_interest ||= options[:model_attributes_of_interest]
|
|
32
37
|
end
|
|
33
38
|
|
|
39
|
+
def api_attributes_of_interest
|
|
40
|
+
@api_attributes_of_interest ||= options[:api_attributes_of_interest]
|
|
41
|
+
end
|
|
42
|
+
|
|
34
43
|
def optional_attributes_to_include
|
|
35
44
|
@optional_attributes_to_include ||= options[:optional_attributes]
|
|
36
45
|
end
|
|
@@ -40,6 +49,7 @@ module PackAPI::Mapping
|
|
|
40
49
|
end
|
|
41
50
|
|
|
42
51
|
def include_optional_api_attribute?(api_attribute_name)
|
|
52
|
+
return true if api_attributes_of_interest && api_attributes_of_interest.include?(api_attribute_name)
|
|
43
53
|
return false if optional_attributes_to_include.nil?
|
|
44
54
|
return false if optional_attributes_to_include.respond_to?(:exclude?) &&
|
|
45
55
|
optional_attributes_to_include.exclude?(api_attribute_name)
|
|
@@ -48,7 +58,7 @@ module PackAPI::Mapping
|
|
|
48
58
|
end
|
|
49
59
|
|
|
50
60
|
def include_model_attribute?(model_attribute)
|
|
51
|
-
return true if model_attributes_of_interest.
|
|
61
|
+
return true if model_attributes_of_interest.nil?
|
|
52
62
|
|
|
53
63
|
model_attributes_of_interest.include?(model_attribute)
|
|
54
64
|
end
|
data/lib/pack_api/version.rb
CHANGED