Module: ActiveRemote::Integration
- Included in:
- Base
- Defined in:
- lib/active_remote/integration.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#cache_key ⇒ Object
Returns a cache key that can be used to identify this record.
-
#to_param ⇒ Object
Returns a String, which can be used for constructing an URL to this object.
Class Method Details
.included(klass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/active_remote/integration.rb', line 3 def self.included(klass) klass.class_eval do unless singleton_methods.include?(:cache_timestamp_format) ## # :singleton-method: # Indicates the format used to generate the timestamp format in the cache key. # This is +:number+, by default. # def self. :number end end end end |
Instance Method Details
#cache_key ⇒ Object
Returns a cache key that can be used to identify this record.
Examples
Product.new.cache_key # => "products/new"
Person.search(:guid => "derp-5").cache_key # => "people/derp-5-20071224150000" (include updated_at)
Product.search(:guid => "derp-5").cache_key # => "products/derp-5"
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/active_remote/integration.rb', line 40 def cache_key case when new_record? then "#{self.class.name.underscore}/new" when ::ActiveRemote.config.default_cache_key_updated_at? && ( = self[:updated_at]) then = .utc.to_s(self.class.) "#{self.class.name.underscore}/#{self.to_param}-#{}" else "#{self.class.name.underscore}/#{self.to_param}" end end |
#to_param ⇒ Object
Returns a String, which can be used for constructing an URL to this object. The default implementation returns this record's guid as a String, or nil if this record's unsaved.
user = User.search(:name => 'Phusion')
user.to_param # => "GUID-1"
27 28 29 |
# File 'lib/active_remote/integration.rb', line 27 def to_param self[:guid] && self[:guid].to_s end |