summaryrefslogtreecommitdiff
path: root/lib/chef/dsl/rest_resource.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/dsl/rest_resource.rb')
-rw-r--r--lib/chef/dsl/rest_resource.rb78
1 files changed, 33 insertions, 45 deletions
diff --git a/lib/chef/dsl/rest_resource.rb b/lib/chef/dsl/rest_resource.rb
index d324d85ed4..055904e1c2 100644
--- a/lib/chef/dsl/rest_resource.rb
+++ b/lib/chef/dsl/rest_resource.rb
@@ -1,63 +1,51 @@
class Chef
module DSL
module RestResource
- module ClassMethods
- def rest_property_map(rest_property_map = "NOT_PASSED")
- if rest_property_map != "NOT_PASSED"
- rest_property_map = rest_property_map.to_h { |k| [k.to_sym, k] } if rest_property_map.is_a? Array
+ def rest_property_map(rest_property_map = "NOT_PASSED")
+ if rest_property_map != "NOT_PASSED"
+ rest_property_map = rest_property_map.to_h { |k| [k.to_sym, k] } if rest_property_map.is_a? Array
- @rest_property_map = rest_property_map
- end
- @rest_property_map
- end
-
- # URL to collection
- def rest_api_collection(rest_api_collection = "NOT_PASSED")
- @rest_api_collection = rest_api_collection if rest_api_collection != "NOT_PASSED"
- @rest_api_collection
+ @rest_property_map = rest_property_map
end
+ @rest_property_map
+ end
- # RFC6570-Templated URL to document
- def rest_api_document(rest_api_document = "NOT_PASSED", first_element_only: false)
- if rest_api_document != "NOT_PASSED"
- @rest_api_document = rest_api_document
- @rest_api_document_first_element_only = first_element_only
- end
- @rest_api_document
- end
+ # URL to collection
+ def rest_api_collection(rest_api_collection = "NOT_PASSED")
+ @rest_api_collection = rest_api_collection if rest_api_collection != "NOT_PASSED"
+ @rest_api_collection
+ end
- # Explicit REST document identity mapping
- def rest_identity_map(rest_identity_map = "NOT_PASSED")
- @rest_identity_map = rest_identity_map if rest_identity_map != "NOT_PASSED"
- @rest_identity_map
+ # RFC6570-Templated URL to document
+ def rest_api_document(rest_api_document = "NOT_PASSED", first_element_only: false)
+ if rest_api_document != "NOT_PASSED"
+ @rest_api_document = rest_api_document
+ @rest_api_document_first_element_only = first_element_only
end
+ @rest_api_document
+ end
- # Mark up properties for POST only, not PATCH/PUT
- def rest_post_only_properties(rest_post_only_properties = "NOT_PASSED")
- if rest_post_only_properties != "NOT_PASSED"
- @rest_post_only_properties = Array(rest_post_only_properties).map(&:to_sym)
- end
- @rest_post_only_properties || []
- end
+ # Explicit REST document identity mapping
+ def rest_identity_map(rest_identity_map = "NOT_PASSED")
+ @rest_identity_map = rest_identity_map if rest_identity_map != "NOT_PASSED"
+ @rest_identity_map
+ end
- def rest_api_document_first_element_only(rest_api_document_first_element_only = "NOT_PASSED")
- if rest_api_document_first_element_only != "NOT_PASSED"
- @rest_api_document_first_element_only = rest_api_document_first_element_only
- end
- @rest_api_document_first_element_only
+ # Mark up properties for POST only, not PATCH/PUT
+ def rest_post_only_properties(rest_post_only_properties = "NOT_PASSED")
+ if rest_post_only_properties != "NOT_PASSED"
+ @rest_post_only_properties = Array(rest_post_only_properties).map(&:to_sym)
end
+ @rest_post_only_properties || []
+ end
- # "What if this was built into Chef Infra Core?" demo only
- def resource_type(resource_type = "NOT_PASSED"); end
-
- def included(other)
- other.extend ClassMethods
+ def rest_api_document_first_element_only(rest_api_document_first_element_only = "NOT_PASSED")
+ if rest_api_document_first_element_only != "NOT_PASSED"
+ @rest_api_document_first_element_only = rest_api_document_first_element_only
end
+ @rest_api_document_first_element_only
end
- def self.included(other)
- other.extend ClassMethods
- end
end
end
end