module Property::StoredColumn

This module should be inserted in an ActiveRecord class that stores a single property definition in the database and is used with StoredRole.

Public Class Methods

included(base) click to toggle source
# File lib/property/stored_column.rb, line 5
def self.included(base)
  base.before_validation :set_index
end

Public Instance Methods

default() click to toggle source

Default values not currently supported.

# File lib/property/stored_column.rb, line 10
def default
  nil
end
klass() click to toggle source

Used to store serialized properties. Should return the class to serialize.

# File lib/property/stored_column.rb, line 15
def klass
  nil
end
options() click to toggle source

No supported options yet.

# File lib/property/stored_column.rb, line 20
def options
  {:index => (index.blank? ? nil : index)}
end
type_cast(value) click to toggle source

Dummy, can be reimplemented in the class storing the column.

# File lib/property/stored_column.rb, line 25
def type_cast(value)
  nil
end

Private Instance Methods

set_index() click to toggle source
# File lib/property/stored_column.rb, line 30
def set_index
  if index == true
    self.index = ptype.to_s
  elsif index.blank?
    self.index = nil
  else
    self.index = self.index.to_s
  end
end