Sha256: 5e051bcd64b4c659c1c2768fb638fdf624e58dafe1d9c7a7466537d35df7fd03

Contents?: true

Size: 538 Bytes

Versions: 2

Compression:

Stored size: 538 Bytes

Contents

class Kredis::Types::List < Kredis::Types::Proxying
  proxying :lrange, :lrem, :lpush, :rpush

  attr_accessor :typed

  def elements
    strings_to_types(lrange(0, -1) || [], typed)
  end
  alias to_a elements

  def remove(*elements)
    types_to_strings(elements, typed).each { |element| lrem 0, element }
  end

  def prepend(*elements)
    lpush types_to_strings(elements, typed) if elements.flatten.any?
  end

  def append(*elements)
    rpush types_to_strings(elements, typed) if elements.flatten.any?
  end
  alias << append
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kredis-0.4.0 lib/kredis/types/list.rb
kredis-0.3.1 lib/kredis/types/list.rb