Class: Hold::InMemory::Cell

Inherits:
Object
  • Object
show all
Includes:
Cell
Defined in:
lib/hold/in_memory/cell.rb

Direct Known Subclasses

ObjectCell

Instance Method Summary collapse

Methods included from Cell

#can_get_class?, #can_set_class?, #get_unless_empty, #set_if_empty, #set_unless_empty, #value, #value=

Constructor Details

#initialize(value = ARG_EMPTY) ⇒ Cell

new – empty new(nil) – non-empty, value is nil new(123) – non-empty, value is 123



9
10
11
# File 'lib/hold/in_memory/cell.rb', line 9

def initialize(value=ARG_EMPTY)
  @value = value unless ARG_EMPTY.equal?(value)
end

Instance Method Details

#clearObject



25
26
27
# File 'lib/hold/in_memory/cell.rb', line 25

def clear
  remove_instance_variable(:@value) if instance_variable_defined?(:@value)
end

#empty?Boolean



21
22
23
# File 'lib/hold/in_memory/cell.rb', line 21

def empty?
  !instance_variable_defined?(:@value)
end

#getObject



13
14
15
# File 'lib/hold/in_memory/cell.rb', line 13

def get
  @value
end

#set(value) ⇒ Object



17
18
19
# File 'lib/hold/in_memory/cell.rb', line 17

def set(value)
  @value = value
end