Class: Hyperactive::List::Element

Inherits:
Record::Bass show all
Includes:
Archipelago::Current::ThreadedCollection
Defined in:
lib/hyperactive/list.rb

Overview

A wrapper class that knows its previous and next List::Elements as well as its value and the id of its list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Transactions::Accessors

append_features

Methods included from Index::Indexable

append_features

Methods included from Record::Persistent

#<=>, append_features, #create, #destroy!, #with_transaction

Constructor Details

#initialize(previous_element, next_element, value, list_id) ⇒ Element

Initialize this List::Element with given previous_element, next_element, value and list_id.



40
41
42
43
44
45
# File 'lib/hyperactive/list.rb', line 40

def initialize(previous_element, next_element, value, list_id)
  self.previous = previous_element
  self.next = next_element
  self.value = value
  self.list_id = list_id
end

Instance Attribute Details

#list_idObject

Returns the value of attribute list_id.



35
36
37
# File 'lib/hyperactive/list.rb', line 35

def list_id
  @list_id
end

#nextObject

Returns the value of attribute next.



35
36
37
# File 'lib/hyperactive/list.rb', line 35

def next
  @next
end

#previousObject

Returns the value of attribute previous.



35
36
37
# File 'lib/hyperactive/list.rb', line 35

def previous
  @previous
end

#valueObject

Returns the value of attribute value.



35
36
37
# File 'lib/hyperactive/list.rb', line 35

def value
  @value
end

Instance Method Details

#each(&block) ⇒ Object

Yield to block once for this and each following element.



49
50
51
52
53
54
55
# File 'lib/hyperactive/list.rb', line 49

def each(&block)
  element = self
  while element
    yield(element)
    element = self.next
  end
end