module Voynich::ActiveModel::Model

Constants

VOYNICH_DEFAULT_OPTIONS

Public Instance Methods

voynich_context(name) click to toggle source
# File lib/voynich/active_model/model.rb, line 14
def voynich_context(name)
  context_proc = voynich_targets[name.to_sym][:context]
  if context_proc
    context_proc.call(self)
  else
    {}
  end
end
voynich_store_attributes() click to toggle source
# File lib/voynich/active_model/model.rb, line 23
def voynich_store_attributes
  voynich_targets.each do |name, options|
    iv = instance_variable_get(:"@#{name}")
    next if iv.nil?

    column_name = voynich_column_name(name)
    value = send(column_name) || send("build_#{column_name}")
    value.context = voynich_context(name)
    value.plain_value = iv
    value.save!
  end
end