Class: DTK::Common::SimpleOrderedHash
- Inherits:
-
Hash
- Object
- Hash
- DTK::Common::SimpleOrderedHash
- Defined in:
- lib/hash_object.rb
Overview
require ‘active_support/ordered_hash’ class SimpleOrderedHash < ::ActiveSupport::OrderedHash
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(elements = []) ⇒ SimpleOrderedHash
constructor
A new instance of SimpleOrderedHash.
-
#set_unless_nil(k, v) ⇒ Object
set unless value is nill.
Constructor Details
#initialize(elements = []) ⇒ SimpleOrderedHash
Returns a new instance of SimpleOrderedHash.
32 33 34 35 36 |
# File 'lib/hash_object.rb', line 32 def initialize(elements=[]) super() elements = [elements] unless elements.kind_of?(Array) elements.each{|el|self[el.keys.first] = el.values.first} end |
Instance Method Details
#set_unless_nil(k, v) ⇒ Object
set unless value is nill
39 40 41 |
# File 'lib/hash_object.rb', line 39 def set_unless_nil(k,v) self[k] = v unless v.nil? end |