Class: Nitron::Data::Relation
- Inherits:
-
NSFetchRequest
- Object
- NSFetchRequest
- Nitron::Data::Relation
- Defined in:
- lib/nitron/data/relation.rb
Instance Method Summary collapse
- #all ⇒ Object
- #first ⇒ Object
- #initWithClass(entityClass) ⇒ Object
- #inspect ⇒ Object
- #order(column, opts = {}) ⇒ Object
- #to_a ⇒ Object
- #where(format, *args) ⇒ Object
Instance Method Details
#all ⇒ Object
12 13 14 |
# File 'lib/nitron/data/relation.rb', line 12 def all self end |
#first ⇒ Object
16 17 18 19 20 |
# File 'lib/nitron/data/relation.rb', line 16 def first setFetchLimit(1) to_a[0] end |
#initWithClass(entityClass) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/nitron/data/relation.rb', line 4 def initWithClass(entityClass) if init setEntity(entityClass.entityDescription) end self end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/nitron/data/relation.rb', line 22 def inspect to_a end |
#order(column, opts = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/nitron/data/relation.rb', line 26 def order(column, opts={}) descriptors = sortDescriptors || [] descriptors << NSSortDescriptor.alloc.initWithKey(column.to_s, ascending:opts.fetch(:ascending, true)) setSortDescriptors(descriptors) self end |
#to_a ⇒ Object
35 36 37 38 |
# File 'lib/nitron/data/relation.rb', line 35 def to_a error = Pointer.new(:object) context.executeFetchRequest(self, error:error) end |
#where(format, *args) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nitron/data/relation.rb', line 40 def where(format, *args) predicate = NSPredicate.predicateWithFormat(format.gsub("?", "%@"), argumentArray:args) if self.predicate self.predicate = NSCompoundPredicate.andPredicateWithSubpredicates([predicate]) else self.predicate = predicate end self end |