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
-
#on_auth(options = {}, &block) ⇒ Object
Calls the block when the value is true.
- #on_disconnect(value, priority: priority, &and_then) ⇒ Object
- #priority(value, &and_then) ⇒ Object
- #priority=(value) ⇒ Object
- #run(options = {}, &transaction) ⇒ Object
- #set(value, priority: priority, &and_then) ⇒ Object
- #to_s ⇒ 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 return FEventTypeChildAdded when :child_moved, :moved FEventTypeChildMoved when :child_changed, :changed return FEventTypeChildChanged when :child_removed, :removed return FEventTypeChildRemoved when :value 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
99 100 101 102 103 |
# File 'lib/firebase/firebase.rb', line 99 def <<(value) ref = childByAutoId ref.update(value) return ref end |
#[](*names) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/firebase/firebase.rb', line 74 def [](*names) if names.length == 0 childByAutoId else childByAppendingPath(names.join('/')) end end |
#[]=(key, value) ⇒ Object
86 87 88 |
# File 'lib/firebase/firebase.rb', line 86 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
47 48 49 |
# File 'lib/firebase/firebase.rb', line 47 def auth_state self.root[".info/authenticated"] end |
#cancel_disconnect(&and_then) ⇒ Object
149 150 151 152 153 154 155 156 |
# File 'lib/firebase/firebase.rb', line 149 def cancel_disconnect(&and_then) if and_then cancelDisconnectOperationsWithCompletionBlock(and_then) else cancelDisconnectOperations end return self end |
#child(name) ⇒ Object
82 83 84 |
# File 'lib/firebase/firebase.rb', line 82 def child(name) childByAppendingPath(name) end |
#clear!(&and_then) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/firebase/firebase.rb', line 90 def clear!(&and_then) if and_then removeValueWithCompletionBlock(and_then) else removeValue end return self end |
#inspect ⇒ Object
197 198 199 |
# File 'lib/firebase/firebase.rb', line 197 def inspect "#<#{self.class}:0x#{self.object_id.to_s(16)}>" end |
#on_auth(options = {}, &block) ⇒ Object
Calls the block when the value is true
159 160 161 |
# File 'lib/firebase/firebase.rb', line 159 def on_auth(={}, &block) auth_state.on(:value, , &block) end |
#on_disconnect(value, priority: priority, &and_then) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/firebase/firebase.rb', line 163 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 == :remove onDisconnectRemoveValue elsif NSDictionary === value onDisconnectUpdateChildValues(value) else onDisconnectSetValue(value) end end return self end |
#priority(value, &and_then) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/firebase/firebase.rb', line 122 def priority(value, &and_then) if and_then setPriority(value, withCompletionBlock:and_then) else setPriority(value) end return self end |
#priority=(value) ⇒ Object
118 119 120 |
# File 'lib/firebase/firebase.rb', line 118 def priority=(value) priority(value) end |
#run(options = {}, &transaction) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/firebase/firebase.rb', line 51 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
109 110 111 112 113 114 115 116 |
# File 'lib/firebase/firebase.rb', line 109 def set(value, &and_then) if and_then setValue(value, withCompletionBlock:and_then) else setValue(value) end return self end |
#to_s ⇒ Object
193 194 195 |
# File 'lib/firebase/firebase.rb', line 193 def to_s description end |
#update(values, &and_then) ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/firebase/firebase.rb', line 140 def update(values, &and_then) if and_then updateChildValues(values, withCompletionBlock:and_then) else updateChildValues(values) end return self end |
#value=(value) ⇒ Object
105 106 107 |
# File 'lib/firebase/firebase.rb', line 105 def value=(value) setValue(value) end |