Sha256: b9c0a587fb18b17a7cd15888d628e5d7a37c3d907b1bb9d035afe4a2709a0259

Contents?: true

Size: 687 Bytes

Versions: 11

Compression:

Stored size: 687 Bytes

Contents

module Conjur
  module HasAttributes
    def to_json(options = {})
      attributes
    end

    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

11 entries across 11 versions & 1 rubygems

Version Path
conjur-api-2.7.1 lib/conjur/has_attributes.rb
conjur-api-2.5.1 lib/conjur/has_attributes.rb
conjur-api-2.4.0 lib/conjur/has_attributes.rb
conjur-api-2.3.1 lib/conjur/has_attributes.rb
conjur-api-2.2.3 lib/conjur/has_attributes.rb
conjur-api-2.2.2 lib/conjur/has_attributes.rb
conjur-api-2.2.1 lib/conjur/has_attributes.rb
conjur-api-2.1.8 lib/conjur/has_attributes.rb
conjur-api-2.1.7 lib/conjur/has_attributes.rb
conjur-api-2.1.6 lib/conjur/has_attributes.rb
conjur-api-2.1.5 lib/conjur/has_attributes.rb