Sha256: f85e838c95bebc02b1ee347d3af502140e835e83585bc5a30df281242d06ea53

Contents?: true

Size: 966 Bytes

Versions: 4

Compression:

Stored size: 966 Bytes

Contents

module Rico
  class Value
    include Rico::Object

    # Gets the value of the object
    #
    # Returns the deserialized value
    alias_method :get, :data

    # Sets and stores the new value for the object
    #
    # value - the new value to store
    #
    # Returns the result of the store operation
    alias_method :set, :mutate

    # Sets the value if it does not exist
    #
    # value - the value to store
    #
    # Returns true if stored, false if not
    def setnx(value)
      if exists?
        false
      else
        set value
        true
      end
    end

    # Resolve conflict between one or more RObject siblings
    #
    # This currently just returns the first sibling
    #
    # robjects - array of RObjects to resolve
    #
    # Returns a single RObject result or nil
    def self.resolve(robject)
      obj = Riak::RObject.new(robject.bucket, robject.key)
      obj.data = robject.siblings.first.data
      obj
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rico-0.4.0 lib/rico/value.rb
rico-0.3.0 lib/rico/value.rb
rico-0.2.0 lib/rico/value.rb
rico-0.1.0 lib/rico/value.rb