module Mooset::Findable::InstanceMethods
Public Instance Methods
find(opts, *args)
click to toggle source
# File lib/mooset/findable.rb, line 50 def find(opts, *args) logger.debug "find #{opts}" return find_from_hash(opts, *args) if opts.is_a? Hash find_from_object(opts, args) end
find_from_hash(hash)
click to toggle source
# File lib/mooset/findable.rb, line 38 def find_from_hash(hash) key, value = hash.find { |(k, _)| respond_to? self.class.finder_method_name(k) } args = hash.tap do |h| h.delete(key) end if key && value public_send(self.class.finder_method_name(key), value, args) end end
find_from_object(object, *args)
click to toggle source
# File lib/mooset/findable.rb, line 30 def find_from_object(object, *args) finder = object.finders.find { |x| respond_to? self.class.finder_method_name(x) } if finder && object[finder] public_send(self.class.finder_method_name(finder), object[finder], *args) end end
import(object)
click to toggle source
# File lib/mooset/findable.rb, line 22 def import(object) logger.debug "import #{object}" method = self.class.import_method_name(object.provider) public_send(method, object) end