class Flattery::ValueCache::Processor

Public Instance Methods

before_save(record) click to toggle source

Command: updates cached values for related changed attributes

# File lib/flattery/value_cache/processor.rb, line 4
def before_save(record)
  resolved_options!(record.class).each do |key,options|
    if record.changed & options[:changed_on]
      record.send("#{key}=", record.send(options[:from_entity]).try(:send,options[:to_entity]))
    end
  end
  true
end
resolved_options!(klass) click to toggle source

Command: resolves value cache options for klass if required, and returns resolved options

# File lib/flattery/value_cache/processor.rb, line 14
def resolved_options!(klass)
  klass.value_cache_options.settings
end