Class: Etapper::EtapHash
- Inherits:
-
Hash
- Object
- Hash
- Etapper::EtapHash
- 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
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#detailed ⇒ Object
readonly
Returns the value of attribute detailed.
-
#etapper_class ⇒ Object
readonly
Returns the value of attribute etapper_class.
Instance Method Summary collapse
- #[]=(key, val) ⇒ Object
- #hash_assign ⇒ Object
-
#initialize(array_from_api, etapper_class, key_symbol, value_symbol) ⇒ EtapHash
constructor
A new instance of EtapHash.
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
#base ⇒ Object (readonly)
Returns the value of attribute base.
6 7 8 |
# File 'lib/etapper/classes/etap_hash.rb', line 6 def base @base end |
#detailed ⇒ Object (readonly)
Returns the value of attribute detailed.
6 7 8 |
# File 'lib/etapper/classes/etap_hash.rb', line 6 def detailed @detailed end |
#etapper_class ⇒ Object (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_assign ⇒ Object
7 |
# File 'lib/etapper/classes/etap_hash.rb', line 7 alias_method :hash_assign, :[]= |