Module: Granite::Form::ActiveRecord::Associations

Extended by:
ActiveSupport::Concern
Defined in:
lib/granite/form/active_record/associations.rb

Defined Under Namespace

Modules: Reflections

Constant Summary collapse

READER =
lambda do |ref, object|
  value = object.read_attribute(ref.name)
  if value.present?
    value.is_a?(String) ? JSON.parse(value) : value
  end
end
WRITER =
lambda do |ref, object, value|
  object.send(:write_attribute, ref.name, value ? value.to_json : nil)
end