Class: Firebase
- Inherits:
-
Object
- Object
- Firebase
- Defined in:
- lib/motion/Firebase+RMXFirebase.rb
Constant Summary collapse
- DEBUG_SETVALUE =
RMX::Env['rmx_firebase_debug_setvalue'] == '1'
Instance Method Summary collapse
- #[](*names) ⇒ Object
- #ending_at(priority) ⇒ Object
- #limited(limit) ⇒ Object
- #orig_setValue ⇒ Object
- #rmx_arrayToHash(array) ⇒ Object
- #rmx_castValue(value, key = nil) ⇒ Object
- #rmx_object_desc ⇒ Object
- #rmx_onDisconnectSetValue(value) ⇒ Object
- #rmx_setValue(value) ⇒ Object
- #setValue(value) ⇒ Object
- #starting_at(priority) ⇒ Object
Instance Method Details
#[](*names) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 9 def [](*names) if names.length == 0 childByAutoId else childByAppendingPath(names.join('/')) end end |
#ending_at(priority) ⇒ Object
25 26 27 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 25 def ending_at(priority) queryEndingAtPriority(priority) end |
#limited(limit) ⇒ Object
17 18 19 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 17 def limited(limit) queryLimitedToNumberOfChildren(limit) end |
#orig_setValue ⇒ Object
75 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 75 alias_method 'orig_setValue', 'setValue' |
#rmx_arrayToHash(array) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 29 def rmx_arrayToHash(array) hash = {} array.each_with_index do |item, i| hash[i.to_s] = item end hash end |
#rmx_castValue(value, key = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 37 def rmx_castValue(value, key=nil) if value == true elsif value == false elsif value.is_a?(NSString) elsif value.is_a?(NSNumber) elsif value.nil? p "FIREBASE_BAD_TYPE FIXED NIL: #{File.join(*[ description, key ].compact.map(&:to_s))}", "!" value = {} elsif value.is_a?(Array) value = rmx_arrayToHash(value) p "FIREBASE_BAD_TYPE FIXED ARRAY: #{File.join(*[ description, key ].compact.map(&:to_s))}: #{value.inspect} (type: #{value.className.to_s})", "!" elsif value.is_a?(NSDictionary) _value = value.dup new_value = {} _value.keys.each do |k| new_value[k.to_s] = rmx_castValue(_value[k], k) end value = new_value else p "FIREBASE_BAD_TYPE FATAL: #{File.join(*[ description, key ].compact.map(&:to_s))}: #{value.inspect} (type: #{value.className.to_s})", "!" end # always return the value, corrected or not value end |
#rmx_object_desc ⇒ Object
5 6 7 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 5 def rmx_object_desc "#{super}:#{description}" end |
#rmx_onDisconnectSetValue(value) ⇒ Object
70 71 72 73 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 70 def rmx_onDisconnectSetValue(value) value = rmx_castValue(value) onDisconnectSetValue(value) end |
#rmx_setValue(value) ⇒ Object
62 63 64 65 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 62 def rmx_setValue(value, andPriority:priority) # value = rmx_castValue(value) setValue(value, andPriority:priority) end |
#setValue(value) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 78 def setValue(value, andPriority:priority) if DEBUG_SETVALUE p description, "setValue:andPriority", value, priority end value = rmx_castValue(value) orig_setValueAndPriority(value, priority) end |
#starting_at(priority) ⇒ Object
21 22 23 |
# File 'lib/motion/Firebase+RMXFirebase.rb', line 21 def starting_at(priority) queryStartingAtPriority(priority) end |