Class: Firebase
- Inherits:
-
Object
- Object
- Firebase
- Defined in:
- lib/firebase/firebase.rb
Constant Summary collapse
- ERRORS =
{ -9999 => :email_in_use, -2 => :wrong_password, }
Class Method Summary collapse
Instance Method Summary collapse
- #<<(value) ⇒ Object
- #[](*names) ⇒ Object
- #[]=(key, value) ⇒ Object
- #auth(credential, options = {}, &and_then) ⇒ Object
- #auth_state ⇒ Object
- #cancel_disconnect(&and_then) ⇒ Object
- #child(name) ⇒ Object
- #clear!(&and_then) ⇒ Object
- #inspect ⇒ Object
- #offline! ⇒ Object
-
#on_auth(options = {}, &block) ⇒ Object
Calls the block when the value is true.
- #on_disconnect(value, priority: priority, &and_then) ⇒ Object
- #online! ⇒ Object
- #priority(value, &and_then) ⇒ Object
- #priority=(value) ⇒ Object
- #push(value, &and_then) ⇒ Object
- #run(options = {}, &transaction) ⇒ Object
- #set(value, priority: priority, &and_then) ⇒ Object
- #to_s ⇒ Object
- #unauth(&block) ⇒ Object
- #update(values, &and_then) ⇒ Object
- #value=(value) ⇒ Object
Class Method Details
.convert_event_type(event_type) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/firebase/firebase.rb', line 7 def self.convert_event_type(event_type) case event_type when :child_added, :added, FEventTypeChildAdded return FEventTypeChildAdded when :child_moved, :moved, FEventTypeChildMoved return FEventTypeChildMoved when :child_changed, :changed, FEventTypeChildChanged return FEventTypeChildChanged when :child_removed, :removed, FEventTypeChildRemoved return FEventTypeChildRemoved when :value, FEventTypeValue return FEventTypeValue else NSLog("Unknown event type #{event_type.inspect}") end return event_type end |
.dispatch_queue=(queue) ⇒ Object
32 33 34 |
# File 'lib/firebase/firebase.rb', line 32 def self.dispatch_queue=(queue) setDispatchQueue(queue) end |
.new(url) ⇒ Object
25 26 27 |
# File 'lib/firebase/firebase.rb', line 25 def self.new(url) alloc.initWithUrl(url) end |
Instance Method Details
#<<(value) ⇒ Object
115 116 117 118 119 |
# File 'lib/firebase/firebase.rb', line 115 def <<(value) ref = childByAutoId ref.set(value) return ref end |
#[](*names) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/firebase/firebase.rb', line 90 def [](*names) if names.length == 0 childByAutoId else childByAppendingPath(names.join('/')) end end |
#[]=(key, value) ⇒ Object
102 103 104 |
# File 'lib/firebase/firebase.rb', line 102 def []=(key, value) childByAppendingPath(key).set(value) end |
#auth(credential, options = {}, &and_then) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/firebase/firebase.rb', line 40 def auth(credential, ={}, &and_then) and_then = and_then || [:completion] disconnect_block = [:disconnect] authWithCredential(credential, withCompletionBlock: and_then, withCancelBlock: disconnect_block) return self end |
#auth_state ⇒ Object
55 56 57 |
# File 'lib/firebase/firebase.rb', line 55 def auth_state self.root[".info/authenticated"] end |
#cancel_disconnect(&and_then) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/firebase/firebase.rb', line 171 def cancel_disconnect(&and_then) if and_then cancelDisconnectOperationsWithCompletionBlock(and_then) else cancelDisconnectOperations end return self end |
#child(name) ⇒ Object
98 99 100 |
# File 'lib/firebase/firebase.rb', line 98 def child(name) childByAppendingPath(name) end |
#clear!(&and_then) ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/firebase/firebase.rb', line 106 def clear!(&and_then) if and_then removeValueWithCompletionBlock(and_then) else removeValue end return self end |
#inspect ⇒ Object
219 220 221 |
# File 'lib/firebase/firebase.rb', line 219 def inspect "#<#{self.class}:0x#{self.object_id.to_s(16)}>" end |
#offline! ⇒ Object
59 60 61 |
# File 'lib/firebase/firebase.rb', line 59 def offline! goOffline end |
#on_auth(options = {}, &block) ⇒ Object
Calls the block when the value is true
181 182 183 |
# File 'lib/firebase/firebase.rb', line 181 def on_auth(={}, &block) auth_state.on(:value, , &block) end |
#on_disconnect(value, priority: priority, &and_then) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/firebase/firebase.rb', line 185 def on_disconnect(value, &and_then) if and_then if value.nil? onDisconnectRemoveValueWithCompletionBlock(and_then) elsif NSDictionary === value onDisconnectUpdateChildValues(value, withCompletionBlock: and_then) else onDisconnectSetValue(value, withCompletionBlock: and_then) end else if value.nil? onDisconnectRemoveValue elsif NSDictionary === value onDisconnectUpdateChildValues(value) else onDisconnectSetValue(value) end end return self end |
#online! ⇒ Object
63 64 65 |
# File 'lib/firebase/firebase.rb', line 63 def online! goOnline end |
#priority(value, &and_then) ⇒ Object
144 145 146 147 148 149 150 151 |
# File 'lib/firebase/firebase.rb', line 144 def priority(value, &and_then) if and_then setPriority(value, withCompletionBlock: and_then) else setPriority(value) end return self end |
#priority=(value) ⇒ Object
140 141 142 |
# File 'lib/firebase/firebase.rb', line 140 def priority=(value) priority(value) end |
#push(value, &and_then) ⇒ Object
121 122 123 124 125 |
# File 'lib/firebase/firebase.rb', line 121 def push(value, &and_then) ref = childByAutoId ref.set(value, &and_then) return ref end |
#run(options = {}, &transaction) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/firebase/firebase.rb', line 67 def run(={}, &transaction) transaction = transaction || [:transaction] completion_block = [:completion] with_local_events = [:local] if with_local_events.nil? if completion_block runTransactionBlock(transaction, andCompletionBlock: completion_block) else runTransactionBlock(transaction) end else runTransactionBlock(transaction, andCompletionBlock: completion_block, withLocalEvents: with_local_events) end end |
#set(value, priority: priority, &and_then) ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'lib/firebase/firebase.rb', line 131 def set(value, &and_then) if and_then setValue(value, withCompletionBlock: and_then) else setValue(value) end return self end |
#to_s ⇒ Object
215 216 217 |
# File 'lib/firebase/firebase.rb', line 215 def to_s description end |
#unauth(&block) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/firebase/firebase.rb', line 47 def unauth(&block) if block unauthWithCompletionBlock(block) else super() end end |
#update(values, &and_then) ⇒ Object
162 163 164 165 166 167 168 169 |
# File 'lib/firebase/firebase.rb', line 162 def update(values, &and_then) if and_then updateChildValues(values, withCompletionBlock: and_then) else updateChildValues(values) end return self end |
#value=(value) ⇒ Object
127 128 129 |
# File 'lib/firebase/firebase.rb', line 127 def value=(value) setValue(value) end |