Class: FQuery
- Inherits:
-
Object
- Object
- FQuery
- Defined in:
- lib/firebase/fquery.rb
Class Method Summary collapse
Instance Method Summary collapse
- #end_at(priority, child: child) ⇒ Object
- #equal_to(priority, child: child) ⇒ Object
- #limit(limit) ⇒ Object
-
#name ⇒ Object
previously the ‘key’ method was called ‘name’.
- #off(handle = nil) ⇒ Object
- #on(event_type, options = {}, &and_then) ⇒ Object
- #once(event_type, options = {}, &and_then) ⇒ Object
- #query(options = {}, &block) ⇒ Object
- #start_at(priority, child: child) ⇒ Object
Class Method Details
.off(handle = nil) ⇒ Object
56 57 58 |
# File 'lib/firebase/fquery.rb', line 56 def self.off(handle=nil) Firebase.new.off(handle) end |
Instance Method Details
#end_at(priority, child: child) ⇒ Object
84 85 86 |
# File 'lib/firebase/fquery.rb', line 84 def end_at(priority) queryEndingAtPriority(priority) end |
#equal_to(priority, child: child) ⇒ Object
76 77 78 |
# File 'lib/firebase/fquery.rb', line 76 def equal_to(priority) queryEqualToPriority(priority) end |
#limit(limit) ⇒ Object
92 93 94 |
# File 'lib/firebase/fquery.rb', line 92 def limit(limit) queryLimitedToNumberOfChildren(limit) end |
#name ⇒ Object
previously the ‘key’ method was called ‘name’
4 5 6 |
# File 'lib/firebase/fquery.rb', line 4 def name self.key end |
#off(handle = nil) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/firebase/fquery.rb', line 59 def off(handle=nil) if handle removeObserverWithHandle(handle) else removeAllObservers end return self end |
#on(event_type, options = {}, &and_then) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/firebase/fquery.rb', line 8 def on(event_type, ={}, &and_then) and_then = and_then || [:completion] raise "event handler is required" unless and_then raise "event handler must accept one or two arguments" unless and_then.arity == 1 || and_then.arity == 2 event_type = Firebase.convert_event_type(event_type) disconnect_block = [:disconnect] raise ":disconnect handler must not accept any arguments" if disconnect_block && disconnect_block.arity > 0 if and_then.arity == 1 if disconnect_block return observeEventType(event_type, withBlock:and_then, withCancelBlock:disconnect_block) else return observeEventType(event_type, withBlock:and_then) end else if disconnect_block return observeEventType(event_type, andPreviousSiblingNameWithBlock:and_then, withCancelBlock:disconnect_block) else return observeEventType(event_type, andPreviousSiblingNameWithBlock:and_then) end end end |
#once(event_type, options = {}, &and_then) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/firebase/fquery.rb', line 32 def once(event_type, ={}, &and_then) and_then = and_then || [:completion] raise "event handler is required" unless and_then raise "event handler must accept one or two arguments" unless and_then.arity == 1 || and_then.arity == 2 event_type = Firebase.convert_event_type(event_type) disconnect_block = [:disconnect] raise ":disconnect handler must not accept any arguments" if disconnect_block && disconnect_block.arity > 0 if and_then.arity == 1 if disconnect_block return observeSingleEventOfType(event_type, withBlock:and_then, withCancelBlock:disconnect_block) else return observeSingleEventOfType(event_type, withBlock:and_then) end else if disconnect_block return observeSingleEventOfType(event_type, andPreviousSiblingNameWithBlock:and_then, withCancelBlock:disconnect_block) else return observeSingleEventOfType(event_type, andPreviousSiblingNameWithBlock:and_then) end end end |
#query(options = {}, &block) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/firebase/fquery.rb', line 96 def query(={}, &block) fb_query = self if [:order_by_key] fb_query = fb_query.queryOrderedByKey end if [:order_by_priority] fb_query = fb_query.queryOrderedByPriority end if [:order_by] fb_query = fb_query.queryOrderedByChild([:order_by]) end if [:first] fb_query = fb_query.queryLimitedToFirst([:first]) end if [:last] fb_query = fb_query.queryLimitedToLast([:last]) end if [:starting_at] && [:key] fb_query = fb_query.queryStartingAtValue([:starting_at], childKey: [:key]) elsif [:starting_at] fb_query = fb_query.queryStartingAtValue([:starting_at]) end if [:ending_at] && [:key] fb_query = fb_query.queryEndingAtValue([:ending_at], childKey: [:key]) elsif [:ending_at] fb_query = fb_query.queryEndingAtValue([:ending_at]) end if [:equal_to] && [:key] fb_query = fb_query.queryEqualToValue([:equal_to], childKey: [:key]) elsif [:equal_to] fb_query = fb_query.queryEqualToValue([:equal_to]) end if block event_type = .fetch(:on, FEventTypeValue) event_type = Firebase.convert_event_type(event_type) return fb_query.observeEventType(event_type, withBlock: and_then) else fb_query end end |
#start_at(priority, child: child) ⇒ Object
68 69 70 |
# File 'lib/firebase/fquery.rb', line 68 def start_at(priority) queryStartingAtPriority(priority) end |