Sha256: c1153157a49be61686d583b71d7d0c141988e48e9d51c815b59c0fd3b3db6f45

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

ActiveRecord::Schema.define(:version => 0) do
  create_table :settings, :force => true do |t|
    t.string :key
    t.text :value
    t.timestamps
  end
  add_index :settings, [:key], :unique => true, :name => 'key_udx'
end

class Setting < ActiveRecord::Base
  def_druthers :quest, :favourite_colour, :things, :hashish, :change

  def self.default_quest
    "to find the holy grail"
  end

  def self.default_things
    [1, 2, 3]
  end

  def validate_favourite_colour
    errors.add(:value, "invalid is invalid WERD") if value == "invalid"
  end

  class CustomSerialize
    def self.load(val)
      ActiveRecord::Coders::YAMLColumn.new.load(val)
    end

    def self.dump(val)
      val = 'bar' if val == 'foo'
      ActiveRecord::Coders::YAMLColumn.new.dump(val)
    end
  end

  serialize :value, CustomSerialize

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
druthers-1.0.0 test/test_models.rb
druthers-0.0.3 test/test_models.rb