Class: BackpackTF::Response
- Inherits:
-
Object
- Object
- BackpackTF::Response
- Defined in:
- lib/backpack_tf/response.rb
Direct Known Subclasses
Class Method Summary collapse
-
.hash_keys_to_sym(hash) ⇒ Object
checks the data type of the keys of a Hash object if the key is a String, then changes it to a Symbol otherwise, leaves it as is.
-
.interface ⇒ Object
CLASS METHODS.
- .responses(key_val = nil) ⇒ Object
- .to_sym ⇒ Object
Class Method Details
.hash_keys_to_sym(hash) ⇒ Object
checks the data type of the keys of a Hash object if the key is a String, then changes it to a Symbol otherwise, leaves it as is
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/backpack_tf/response.rb', line 38 def self.hash_keys_to_sym hash hash.each_pair.inject({}) do |new_hash, (key, val)| unless key.class == String new_hash[key] = val else new_hash[key.to_sym] = val end new_hash end end |
.interface ⇒ Object
CLASS METHODS
8 |
# File 'lib/backpack_tf/response.rb', line 8 def self.interface; @interface; end |
.responses(key_val = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/backpack_tf/response.rb', line 16 def self.responses key_val = nil unless key_val.nil? key_val = { key_val => nil } unless key_val.class == Hash key = key_val.keys.first val = key_val.values.first if val.nil? @responses[key] elsif key == :reset && val == :confirm @responses = {} else @responses[key] = hash_keys_to_sym(val) end end @responses end |
.to_sym ⇒ Object
10 11 12 |
# File 'lib/backpack_tf/response.rb', line 10 def self.to_sym self.name.to_sym end |