Sha256: dc7e672b54ec3565d89998f3c59996859505d513d171e5eef49806c63e344393

Contents?: true

Size: 501 Bytes

Versions: 6

Compression:

Stored size: 501 Bytes

Contents

# frozen_string_literal: true

require "json"
require "active_record"

module Kanal
  module Plugins
    module UserSystem
      module Helpers
        # Helps using .value property with restoring/saving from
        # json representation in .raw_value model field
        module JsonValueConverterMixin
          def value
            JSON.parse(raw_value)
          end

          def value=(val)
            self.raw_value = JSON.generate(val)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kanal-plugins-user_system-0.3.3 lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb
kanal-plugins-user_system-0.3.2 lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb
kanal-plugins-user_system-0.3.1 lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb
kanal-plugins-user_system-0.3.0 lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb
kanal-plugins-user_system-0.2.1 lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb
kanal-plugins-user_system-0.2.0 lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb