Class: Blix::Rest::StringHash
Overview
indifferent hash for symbols or string keys. stores keys as a string
Class Method Summary collapse
-
.create(params) ⇒ Object
create with conversion.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
- #delete(k) ⇒ Object
- #get(k, default = nil) ⇒ Object
- #has_key?(key) ⇒ Boolean
- #include?(k) ⇒ Boolean
-
#initialize(*params) ⇒ StringHash
constructor
initialize without conversion.
- #key(key) ⇒ Object
- #key?(key) ⇒ Boolean
- #member?(key) ⇒ Boolean
- #merge(*params) ⇒ Object
- #merge!(*params) ⇒ Object
- #parent_merge! ⇒ Object
- #replace(h) ⇒ Object
- #store(key, value) ⇒ Object
Methods inherited from Hash
Constructor Details
#initialize(*params) ⇒ StringHash
initialize without conversion. params must be in string key format.
31 32 33 34 |
# File 'lib/blix/rest/string_hash.rb', line 31 def initialize(*params) super() parent_merge!(*params) unless params.empty? end |
Class Method Details
.create(params) ⇒ Object
create with conversion
37 38 39 40 41 |
# File 'lib/blix/rest/string_hash.rb', line 37 def self.create(params) h = new h.merge(params) h end |
Instance Method Details
#[](k) ⇒ Object
43 44 45 |
# File 'lib/blix/rest/string_hash.rb', line 43 def [](k) super(k.to_s) end |
#[]=(k, v) ⇒ Object
87 88 89 |
# File 'lib/blix/rest/string_hash.rb', line 87 def []=(k, v) super(k.to_s, v) end |
#delete(k) ⇒ Object
95 96 97 |
# File 'lib/blix/rest/string_hash.rb', line 95 def delete(k) super(k.to_s) end |
#get(k, default = nil) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/blix/rest/string_hash.rb', line 47 def get(k, default = nil) if key?(k.to_s) self[k] else default end end |
#has_key?(key) ⇒ Boolean
67 68 69 |
# File 'lib/blix/rest/string_hash.rb', line 67 def has_key?(key) super(key.to_s) end |
#include?(k) ⇒ Boolean
91 92 93 |
# File 'lib/blix/rest/string_hash.rb', line 91 def include?(k) super(k.to_s) end |
#key(key) ⇒ Object
79 80 81 |
# File 'lib/blix/rest/string_hash.rb', line 79 def key(key) super(key.to_s) end |
#key?(key) ⇒ Boolean
83 84 85 |
# File 'lib/blix/rest/string_hash.rb', line 83 def key?(key) super(key.to_s) end |
#member?(key) ⇒ Boolean
71 72 73 |
# File 'lib/blix/rest/string_hash.rb', line 71 def member?(key) super(key.to_s) end |
#merge(*params) ⇒ Object
55 56 57 |
# File 'lib/blix/rest/string_hash.rb', line 55 def merge(*params) super(* params.map { |h| h.transform_keys(&:to_s) }) end |
#merge!(*params) ⇒ Object
59 60 61 |
# File 'lib/blix/rest/string_hash.rb', line 59 def merge!(*params) super(* params.map { |h| h.transform_keys(&:to_s) }) end |
#parent_merge! ⇒ Object
27 |
# File 'lib/blix/rest/string_hash.rb', line 27 alias_method :parent_merge!, :merge! |
#replace(h) ⇒ Object
63 64 65 |
# File 'lib/blix/rest/string_hash.rb', line 63 def replace(h) super(h.transform_keys(&:to_s)) end |
#store(key, value) ⇒ Object
75 76 77 |
# File 'lib/blix/rest/string_hash.rb', line 75 def store(key, value) super(key.to_s, value) end |