Class: Etapper::EtapHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/etapper/classes/etap_hash.rb

Overview

This is a virtual base class for specialized representations of eTapestry API arrays such as PhoneHash, DefinedValueHash, etc. It _should not_ be invoked on its own. It needs the following constants defined in subclasses to work:

Direct Known Subclasses

DefinedValueHash, PhoneHash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array_from_api, etapper_class, key_symbol, value_symbol) ⇒ EtapHash

Returns a new instance of EtapHash.



9
10
11
12
13
14
15
16
17
# File 'lib/etapper/classes/etap_hash.rb', line 9

def initialize(array_from_api, etapper_class, key_symbol, value_symbol)
  @base, @etapper_class, @key_symbol, @value_symbol = array_from_api, etapper_class, key_symbol, value_symbol
  @detailed = Hash.new
  @base.each do |element|
    friendly = etapper_class.new(element)
    add_to_self(friendly)
    add_to_detailed(friendly)  # So we can easily find our objects later
  end
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



6
7
8
# File 'lib/etapper/classes/etap_hash.rb', line 6

def base
  @base
end

#detailedObject (readonly)

Returns the value of attribute detailed.



6
7
8
# File 'lib/etapper/classes/etap_hash.rb', line 6

def detailed
  @detailed
end

#etapper_classObject (readonly)

Returns the value of attribute etapper_class.



6
7
8
# File 'lib/etapper/classes/etap_hash.rb', line 6

def etapper_class
  @etapper_class
end

Instance Method Details

#[]=(key, val) ⇒ Object



19
20
21
22
# File 'lib/etapper/classes/etap_hash.rb', line 19

def []=(key, val)
  update_base(key, val)
  hash_assign(key, val)
end

#hash_assignObject



7
# File 'lib/etapper/classes/etap_hash.rb', line 7

alias_method :hash_assign, :[]=