lib/active_remote/search.rb in active_remote-3.3.3 vs lib/active_remote/search.rb in active_remote-5.0.0.pre
- old
+ new
@@ -1,7 +1,7 @@
-require 'active_remote/persistence'
-require 'active_remote/rpc'
+require "active_remote/persistence"
+require "active_remote/rpc"
module ActiveRemote
module Search
extend ActiveSupport::Concern
@@ -24,13 +24,13 @@
# # Protobuf object
# Tag.find(Generic::Remote::TagRequest.new(:guid => 'foo'))
#
def find(args)
remote = self.search(args).first
- raise RemoteRecordNotFound.new(self) if remote.nil?
+ raise RemoteRecordNotFound, self if remote.nil?
- return remote
+ remote
end
# Tries to load the first record; if it fails, then create is called
# with the same arguments.
#
@@ -89,11 +89,13 @@
args = validate_search_args!(args)
response = remote_call(:search, args)
if response.respond_to?(:records)
- records = serialize_records(response.records)
+ serialize_records(response.records)
+ else
+ response
end
end
# Validates the given args to ensure they are compatible
# Search args must be a hash or respond to to_hash
@@ -113,9 +115,9 @@
# Reload this record from the remote service.
#
def reload
fresh_object = self.class.find(scope_key_hash)
- @attributes.update(fresh_object.instance_variable_get('@attributes'))
+ @attributes.update(fresh_object.instance_variable_get("@attributes"))
end
end
end