lib/active_remote/integration.rb in active_remote-7.0.0 vs lib/active_remote/integration.rb in active_remote-7.1.0
- old
+ new
@@ -7,19 +7,19 @@
# :singleton-method:
# Indicates the format used to generate the timestamp in the cache key, if
# versioning is off. Accepts any of the symbols in <tt>Time::DATE_FORMATS</tt>.
#
# This is +:usec+, by default.
- class_attribute :cache_timestamp_format, :instance_writer => false, :default => :usec
+ class_attribute :cache_timestamp_format, instance_writer: false, default: :usec
##
# :singleton-method:
# Indicates whether to use a stable #cache_key method that is accompanied
# by a changing version in the #cache_version method.
#
# This is +false+, by default until Rails 6.0.
- class_attribute :cache_versioning, :instance_writer => false, :default => false
+ class_attribute :cache_versioning, instance_writer: false, default: false
end
# Returns a +String+, which Action Pack uses for constructing a URL to this
# object. The default implementation returns this record's id as a +String+,
# or +nil+ if this record's unsaved.
@@ -58,14 +58,14 @@
#
# Product.cache_versioning = false
# Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available)
#
def cache_key
- case
- when new_record? then
+ if new_record?
+
"#{model_name.cache_key}/new"
- when ::ActiveRemote.config.default_cache_key_updated_at? && (self.respond_to?(:[]) && timestamp = self["updated_at"]) then
+ elsif ::ActiveRemote.config.default_cache_key_updated_at? && (respond_to?(:[]) && (timestamp = self["updated_at"]))
timestamp = timestamp.utc.to_fs(self.class.cache_timestamp_format)
"#{model_name.cache_key}/#{send(primary_key)}-#{timestamp}"
else
"#{model_name.cache_key}/#{send(primary_key)}"
end
@@ -121,11 +121,11 @@
if method_name.nil?
super()
else
define_method :to_param do
if (default = super()) &&
- (result = send(method_name).to_s).present? &&
- (param = result.squish.parameterize.truncate(20, :separator => /-/, :omission => "")).present?
+ (result = send(method_name).to_s).present? &&
+ (param = result.squish.parameterize.truncate(20, separator: /-/, omission: "")).present?
"#{default}-#{param}"
else
default
end
end