lib/conjur/has_attributes.rb in conjur-api-5.0.0 vs lib/conjur/has_attributes.rb in conjur-api-5.1.0

- old
+ new

@@ -21,10 +21,18 @@ module Conjur # Many Conjur assets have key-value attributes. Although these should generally be accessed via # methods on specific asset classes (for example, {Conjur::Resource#owner}), the are available as # a `Hash` on all types supporting attributes. module HasAttributes + class << self + + # @api private + def annotation_value annotations, name + (annotations.find{|a| a['name'] == name} || {})['value'] + end + end + def as_json options={} result = super(options) if @attributes result.merge!(@attributes.as_json(options)) end @@ -65,23 +73,23 @@ protected def annotation_value name - (attributes['annotations'].find{|a| a['name'] == name} || {})['value'] + HasAttributes.annotation_value attributes['annotations'], name end # @api private # Fetch the attributes, overwriting any current ones. def fetch @attributes ||= fetch_attributes end # @api private def fetch_attributes - cache_key = Conjur.cache_key username, rbac_resource_resource.url + cache_key = Conjur.cache_key username, url_for(:resources_resource, credentials, id).url Conjur.cache.fetch_attributes cache_key do - JSON.parse(rbac_resource_resource.get.body) + JSON.parse(url_for(:resources_resource, credentials, id).get.body) end end end end \ No newline at end of file