Class: Cassanity::CollectionItem

Inherits:
Object
  • Object
show all
Defined in:
lib/cassanity/collection_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ CollectionItem

Public: Returns a collection item instance

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
# File 'lib/cassanity/collection_item.rb', line 14

def initialize(key, value)
  raise ArgumentError.new("key cannot be nil") if key.nil?
  raise ArgumentError.new("value cannot be nil") if value.nil?
  
  @key   = key
  @value = value
end

Instance Attribute Details

#keyObject (readonly)

Internal



8
9
10
# File 'lib/cassanity/collection_item.rb', line 8

def key
  @key
end

#valueObject (readonly)

Internal



11
12
13
# File 'lib/cassanity/collection_item.rb', line 11

def value
  @value
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/cassanity/collection_item.rb', line 22

def eql?(other)
  self.class.eql?(other.class) &&
    value == other.value &&
    key == other.key
end

#inspectObject

Public



31
32
33
34
35
36
37
# File 'lib/cassanity/collection_item.rb', line 31

def inspect
  attributes = [
    "key=#{key.inspect}",
    "value=#{value.inspect}",
  ]
  "#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>"
end