Class: DeepStruct::DeepWrapper

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

Direct Known Subclasses

ArrayWrapper, HashWrapper

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ DeepWrapper

Returns a new instance of DeepWrapper.



5
6
7
# File 'lib/deepstruct.rb', line 5

def initialize(value)
  @value = value
end

Instance Method Details

#[](index) ⇒ Object



13
14
15
# File 'lib/deepstruct.rb', line 13

def [](index)
  return DeepStruct.wrap(@value[index])
end

#[]=(index, value) ⇒ Object



17
18
19
# File 'lib/deepstruct.rb', line 17

def []=(index, value)
  @value[index] = value
end

#inspectObject



21
22
23
# File 'lib/deepstruct.rb', line 21

def inspect
  "#<#{self.class} #{@value.inspect}>"
end

#to_json(*args) ⇒ Object



25
26
27
# File 'lib/deepstruct.rb', line 25

def to_json(*args)
  @value.to_json(*args)
end

#unwrapObject



9
10
11
# File 'lib/deepstruct.rb', line 9

def unwrap
  @value
end