File: widget.rb

package info (click to toggle)
ruby-activerecord-import 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 840 kB
  • sloc: ruby: 4,698; makefile: 7
file content (26 lines) | stat: -rw-r--r-- 426 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

class CustomCoder
  def load(value)
    if value.nil?
      {}
    else
      YAML.load(value)
    end
  end

  def dump(value)
    YAML.dump(value)
  end
end

class Widget < ActiveRecord::Base
  self.primary_key = :w_id

  default_scope -> { where(active: true) }

  serialize :data, Hash
  serialize :json_data, JSON
  serialize :unspecified_data
  serialize :custom_data, CustomCoder.new
end