Class: Flattery::ValueProvider::Processor
- Inherits:
-
Object
- Object
- Flattery::ValueProvider::Processor
- Defined in:
- lib/flattery/value_provider/processor.rb
Instance Method Summary collapse
-
#after_update(record) ⇒ Object
Command: pushes cache updates for related changed attributes.
-
#apply_push(record, method, attribute, new_value, association_name, target_attribute) ⇒ Object
Command: performs an update for a specific cache setting.
-
#resolved_options!(klass) ⇒ Object
Command: resolves value provider options for
klass
if required, and returns resolved options.
Instance Method Details
#after_update(record) ⇒ Object
Command: pushes cache updates for related changed attributes
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/flattery/value_provider/processor.rb', line 4 def after_update(record) (record.class).each do |key,| if record.changed.include?(key) if target_attribute = [:as] method = [:method] attribute = key.to_sym new_value = record.send(key) association_name = [:to_entity] if [:background_with] == :delayed_job && self.respond_to?(:delay) self.delay.apply_push(record,method,attribute,new_value,association_name,target_attribute) else apply_push(record,method,attribute,new_value,association_name,target_attribute) end else raise Flattery::CacheColumnInflectionError.new("#{record.class.name} #{key}: #{}") end end end true end |
#apply_push(record, method, attribute, new_value, association_name, target_attribute) ⇒ Object
Command: performs an update for a specific cache setting
26 27 28 29 30 31 32 33 |
# File 'lib/flattery/value_provider/processor.rb', line 26 def apply_push(record,method,attribute,new_value,association_name,target_attribute) case method when :update_all record.send(association_name).update_all({target_attribute => new_value}) else # it is a custom update method record.send(method,attribute,new_value,association_name,target_attribute) end end |
#resolved_options!(klass) ⇒ Object
Command: resolves value provider options for klass
if required, and returns resolved options
36 37 38 |
# File 'lib/flattery/value_provider/processor.rb', line 36 def (klass) klass..settings end |