lib/active_remote/search.rb in active_remote-2.0.2 vs lib/active_remote/search.rb in active_remote-2.1.0.beta1
- old
+ new
@@ -89,13 +89,16 @@
# Tag.search(Generic::Remote::TagRequest.new(:name => 'foo'))
#
def search(args)
args = _active_remote_search_args(args)
- remote = self.new
- remote._active_remote_search(args)
- remote.serialize_records
+ response = rpc.execute(:search, args)
+
+ if response.respond_to?(:records)
+ records = serialize_records(response.records)
+ records.each { |record| record.run_callbacks :search }
+ end
end
# :noapi:
def _active_remote_search_args(args)
unless args.is_a?(Hash)
@@ -114,19 +117,19 @@
# for records matching the given search args until all records have been
# retrieved) if no pagination options are given.
#
def _active_remote_search(args)
run_callbacks :search do
- execute(:search, args)
+ rpc.execute(:search, args)
end
end
# Reload this record from the remote service.
#
def reload
- _active_remote_search(:guid => self.guid)
+ response = self.class.find(scope_key_hash)
- fresh_object = self.class.new(last_response.to_hash)
+ fresh_object = self.class.instantiate(response.to_hash)
@attributes.update(fresh_object.instance_variable_get('@attributes'))
end
end
end