Class: Command::DecoratingHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/command/decoratinghash.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#targetObject

Returns the value of attribute target.



11
12
13
# File 'lib/command/decoratinghash.rb', line 11

def target
  @target
end

Class Method Details

.new(target) ⇒ Object



13
14
15
16
17
# File 'lib/command/decoratinghash.rb', line 13

def self.new(target)
  obj = super() do |h,k| h.target && h.target[k] end
  obj.target = target
  obj
end

Instance Method Details

#keysObject



27
28
29
# File 'lib/command/decoratinghash.rb', line 27

def keys
  @target ? (super | @target.keys) : super
end

#own_sizeObject Also known as: own_length



19
# File 'lib/command/decoratinghash.rb', line 19

alias own_size size

#sizeObject Also known as: length



22
23
24
# File 'lib/command/decoratinghash.rb', line 22

def size
  @target ? keys.size : super
end