Sha256: 149e1709809adedb55b325c81901b080a8273e0c68929b3d8fb8ea0dd4e9b7a1

Contents?: true

Size: 631 Bytes

Versions: 4

Compression:

Stored size: 631 Bytes

Contents

module Conjur
  module HasAttributes
    def attributes=(a); @attributes = a; end
    def attributes
      return @attributes if @attributes
      fetch
    end
    
    def save
      self.put(attributes.to_json)
    end
    
    # Reload the attributes. This action can be used to guarantee a current view of the entity in the case
    # that it has been modified by an update method or by an external party.
    def refresh
      fetch
    end
    
    protected
    
    def invalidate(&block)
      yield
    ensure
      @attributes = nil
    end
    
    def fetch
      @attributes = JSON.parse(get.body)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
conjur-api-2.1.4 lib/conjur/has_attributes.rb
conjur-api-2.1.3 lib/conjur/has_attributes.rb
conjur-api-2.1.2 lib/conjur/has_attributes.rb
conjur-api-2.1.1 lib/conjur/has_attributes.rb