module MotionDataWrapper::Model::FinderMethods::ClassMethods
Public Instance Methods
except(query_part)
click to toggle source
@param [Symbol] query part to exclude, ie :where or :limit @returns [Relation]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 20 def except(query_part) relation.except(query_part) end
find(object_id)
click to toggle source
@param [id] id to retrieve record by @raises [RecordNotFound] @returns [Model]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 32 def find(object_id) find_by_id!(object_id) end
first()
click to toggle source
@returns [Model] or nil
# File lib/motion_data_wrapper/model/finder_methods.rb, line 25 def first relation.first end
last()
click to toggle source
@returns [Model] or nil
# File lib/motion_data_wrapper/model/finder_methods.rb, line 37 def last relation.last end
limit(l)
click to toggle source
@param [Fixnum] @returns [Relation]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 43 def limit(l) relation.limit(l) end
offset(o)
click to toggle source
@param [Fixnum] @returns [Relation]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 49 def offset(o) relation.offset(o) end
order(*args)
click to toggle source
@param [Symbol] column @param @optional [Hash] options, key :ascending @returns [Relation]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 56 def order(*args) relation.order(*args) end
pluck(column)
click to toggle source
@param [Symbol] column @returns [Array]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 62 def pluck(column) relation.pluck(column) end
reorder(*args)
click to toggle source
@param [Symbol] column @param @optional [Hash] options, key :ascending @returns [Relation]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 69 def reorder(*args) relation.except(:order).order(*args) end
respond_to?(method)
click to toggle source
Calls superclass method
# File lib/motion_data_wrapper/model/finder_methods.rb, line 73 def respond_to?(method) if method.start_with?("find_by_") || method.start_with?("find_all_by_") true else super end end
where(*args)
click to toggle source
@param [String] conditions @param [vargs] Replacements @returns [Relation] Usage:
where("title contains[cd] ?", "title")
# File lib/motion_data_wrapper/model/finder_methods.rb, line 86 def where(*args) relation.where(*args) end
with_context(ctx)
click to toggle source
@param [NSManagedObjectContext] @param [Relation]
# File lib/motion_data_wrapper/model/finder_methods.rb, line 92 def with_context(ctx) relation.with_context(ctx) end
Private Instance Methods
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/motion_data_wrapper/model/finder_methods.rb, line 98 def method_missing(method, *args, &block) if method.start_with?("find_by_") attribute = method.gsub("find_by_", "").gsub("!", "") chain = relation.where("#{attribute} = ?", *args) if method.end_with?("!") chain.first! else chain.first end elsif method.start_with?("find_all_by_") attribute = method.gsub("find_all_by_", "") relation.where("#{attribute} = ?", *args).to_a else super end end
relation()
click to toggle source
# File lib/motion_data_wrapper/model/finder_methods.rb, line 118 def relation Relation.alloc.initWithClass(self) end