class Terrestrial::Configurations::ConventionalConfiguration::ArbitraryDatabaseDefaultValueObserver

Attributes

field_name[R]
setter[R]

Public Class Methods

new(field_name, setter) click to toggle source
# File lib/terrestrial/configurations/conventional_configuration.rb, line 384
def initialize(field_name, setter)
  @field_name = field_name
  @setter = setter
end

Public Instance Methods

post_save(mapping, object, record, new_record) click to toggle source
# File lib/terrestrial/configurations/conventional_configuration.rb, line 395
def post_save(mapping, object, record, new_record)
  if value_changed?(new_record, record)
    setter.call(object, new_record.get(field_name))
  end
end
post_serialize(*_args) click to toggle source
# File lib/terrestrial/configurations/conventional_configuration.rb, line 392
def post_serialize(*_args)
end

Private Instance Methods

value_changed?(new_record, old_record) click to toggle source
# File lib/terrestrial/configurations/conventional_configuration.rb, line 403
def value_changed?(new_record, old_record)
  new_record.attributes[field_name] != old_record.attributes[field_name]
end