Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/google_plus/core_ext/hash.rb
Instance Method Summary collapse
-
#merge_list!(list_id_or_screen_name) ⇒ Hash
Take a single list ID or slug and merge it into the hash with the correct key.
-
#merge_owner!(owner_id_or_owner_screen_name) ⇒ Hash
Take a single owner ID or owner screen name and merge it into the hash with the correct key (for Twitter API endpoints that want :owner_id and :owner_screen_name).
-
#merge_user!(user_id_or_screen_name) ⇒ Hash
Take a single user ID or screen name and merge it into the hash with the correct key.
-
#merge_users!(user_ids_or_screen_names) ⇒ Hash
Take a multiple user IDs and screen names and merge them into the hash with the correct keys.
Instance Method Details
#merge_list!(list_id_or_screen_name) ⇒ Hash
Take a single list ID or slug and merge it into the hash with the correct key
55 56 57 58 59 60 61 62 63 |
# File 'lib/google_plus/core_ext/hash.rb', line 55 def merge_list!(list_id_or_screen_name) case list_id_or_screen_name when Integer self[:list_id] = list_id_or_screen_name when String self[:slug] = list_id_or_screen_name end self end |
#merge_owner!(owner_id_or_owner_screen_name) ⇒ Hash
Take a single owner ID or owner screen name and merge it into the hash with the correct key (for Twitter API endpoints that want :owner_id and :owner_screen_name)
41 42 43 44 45 46 47 48 49 |
# File 'lib/google_plus/core_ext/hash.rb', line 41 def merge_owner!(owner_id_or_owner_screen_name) case owner_id_or_owner_screen_name when Integer self[:owner_id] = owner_id_or_owner_screen_name when String self[:owner_screen_name] = owner_id_or_owner_screen_name end self end |
#merge_user!(user_id_or_screen_name) ⇒ Hash
Take a single user ID or screen name and merge it into the hash with the correct key
7 8 9 10 11 12 13 14 15 |
# File 'lib/google_plus/core_ext/hash.rb', line 7 def merge_user!(user_id_or_screen_name) case user_id_or_screen_name when Integer self[:user_id] = user_id_or_screen_name when String self[:screen_name] = user_id_or_screen_name end self end |
#merge_users!(user_ids_or_screen_names) ⇒ Hash
Take a multiple user IDs and screen names and merge them into the hash with the correct keys
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/google_plus/core_ext/hash.rb', line 21 def merge_users!(user_ids_or_screen_names) user_ids, screen_names = [], [] user_ids_or_screen_names.flatten.each do |user_id_or_screen_name| case user_id_or_screen_name when Integer user_ids << user_id_or_screen_name when String screen_names << user_id_or_screen_name end end self[:user_id] = user_ids.join(',') unless user_ids.empty? self[:screen_name] = screen_names.join(',') unless screen_names.empty? self end |